package com.handinfo.uimenu;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

//#if lucency == "YES"
import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.Animation;
import com.handinfo.engine.GameManager;
import com.handinfo.game.ActorItem;
import com.handinfo.game.ActorItemEquip;
import com.handinfo.game.ActorRole;
import com.handinfo.game.GameScene;
import com.handinfo.game.MenuFunction;
import com.handinfo.game.RoleCombatSkill;
import com.handinfo.util.ArrayList;
import com.handinfo.util.Tools;
//import com.nokia.mid.ui.DirectUtils;
//#endif

public class UITools {
	// 图片标签
	public static final int H_LABEL = 22;// 默认标签高度 - 图片字的高度
	public static final int W_LABEL_SMALL = 26;// 小的标签宽度
	public static final int W_LABEL_MIDDLE = 34;
	public static final int W_LABEL_BIG = 50;
	public static final int W_LABEL_HUGE = 72;// 巨大的标签宽度
	// 动画
	public static final int W_ANIM = 70;// 动画的宽高
	public static final int H_ANIM = 60;// 动画的宽高
	// 按钮
	private static final int IW_IMAGE_SOFT = 2;// 底部按钮离左边宽度
	private static final int IH_IMAGE_SOFT = 3;// 底部按钮离底边高度
	// 道具描述
	public static final int ITEM_DESCRIBEW = 170;// 道具的描述框总宽度
	// 界面WH
	public static final int IW_RECTS = 3;// 框体间间隔
	public static final int IH_RECTS = 3;// 框体间间隔
	public static final int IW_RECT_CONTENT = 3;// 框层到内容层的间隙宽度
	public static final int IH_RECT_CONTENT = 3;// 框层到内容层的间隙高度
	public static final int IW_WIN = 4;// 框层到内容层的间隙宽度
	// 行信息
	public static final int H_PRE = AbstractGameScreen.FONT_H + 2;// 单位行高,字体的高度，加上下间隙
	public static final int H_LABEL_STR = AbstractGameScreen.FONT_H + (IW_RECT_CONTENT << 1);// 用于描述文字标签的高度
	// 界面XY
	public static final int INITX_CONTENT = 8;// 内层框离外框距离
	public static final int W_RECT = UITools.W_BG - (INITX_CONTENT << 1);// 矩形框的宽度
	public static final int W_CONTENT = W_RECT - (IW_RECT_CONTENT << 1);// 内容框宽度
	// 界面变量
	public static int W_RECT_DRAG;// 有下拉条的
	public static int X_DRAG = 0;// 下拉条,相对界面右对齐，可供显示的最顶部Y轴
	//
	public static int INITY_CONTENT = 0;// 可供显示的最顶部Y轴
	public static int H_RECT;// 可供显示的背景高度
	public static int ENDY_CONTENT;// 界面能够绘制元素的最底位置
	// 金钱 - 游戏币
	public static int H_MONEY_GAME;// 游戏币控件实际高度 = 金高度 +(IH_MONEY<<1);
	public static int W_MONEY_RMB;
	public static int H_MONEY_RMB;// 人民币控件实际高度 = 人民币控件高度 +(IH_MONEY<<1);
	public static int W_MONEY_YINPIAO;
	public static int H_MONEY_YINPIAO;
	public static int W_MONEY_ZHANGONG;
	public static int H_MONEY_ZHANGONG;
	public static int W_MONEY_JIAGONG;
	public static int H_MONEY_JIAGONG;
	public static final String GONGXIAN = "贡献点";
	// 背包格子WH
	public static int W_BAG;
	public static int H_BAG;

	private static Image alphaBG; 
	public static final void drawAlphaBG(Graphics g) {
		if (alphaBG == null) {
//			alphaBG = Image.createImage(100, 100);
//			Graphics g1 = alphaBG.getGraphics();
			int len = 100*100;
			int[] rgbData = new int[len];
			for (int i=0;i<len;i++) {
				rgbData[i] = 0x7f000000;
			}
			alphaBG = Image.createRGBImage(rgbData, 100, 100, true);
//			g1.drawRGB(rgbData, 0, 100, 0, 0, 100, 100, true);
		}
		int w=0,h=0;
		for (int i=0;i<AbstractGameScreen.SCREEN_HEIGHT;i += 100) {
			for (int j=0;j<AbstractGameScreen.SCREEN_WIDTH;j+=100) {
				g.drawImage(alphaBG, j, i, Graphics.LEFT|Graphics.TOP);
			}
		}
		
	}
	/**
	 * 初始化界面数据 2012-3-1 下午05:44:09 venizengo
	 */
	public static final void initImage() {
		// 钱
		H_MONEY_GAME = getMoneyGameHeight();
		W_MONEY_RMB = getMoneyRmbWidth();
		H_MONEY_RMB = getMoneyRmbHeight();
		W_MONEY_YINPIAO = getMoneyYinpiaoWidth();
		H_MONEY_YINPIAO = getMoneyYinpiaoHeight();
		W_MONEY_ZHANGONG = getMoneyZhangongWidth();
		H_MONEY_ZHANGONG = getMoneyZhangongHeight();
		W_MONEY_JIAGONG = AbstractGameScreen.s_font.stringWidth(GONGXIAN);
		H_MONEY_JIAGONG = AbstractGameScreen.FONT_H;
		// 背包格子
		W_BAG = UIManager.IMAGE_ITEM_OPEN.getWidth();
		H_BAG = UIManager.IMAGE_ITEM_OPEN.getHeight();
		// 下拉条
		int W_DRAG = UIManager.IMAGE_SCROLL_ARR.getWidth() + 2;// 无下拉条的宽度
		W_RECT_DRAG = W_BG - INITX_CONTENT - IW_WIN - W_DRAG - IW_RECTS;
		X_DRAG = W_BG - IW_WIN - W_DRAG;//
		// 界面量
		//#if screen == "320240"
		//# INITY_CONTENT = UITools.IW_WIN;
		//# H_RECT = H_BG - (UITools.IW_WIN << 1) - (UITools.IH_RECTS << 1);
		//# ENDY_CONTENT = H_BG - UITools.IH_RECT_CONTENT;
		//#else
		INITY_CONTENT = UIManager.IMAGE_TITlE_SMALL.getHeight() + UITools.IH_RECTS;
		H_RECT = H_BG - (INITY_CONTENT + UITools.IW_RECTS) - (H_LABEL + IH_IMAGE_SOFT + UITools.IH_RECTS);
		ENDY_CONTENT = H_BG - (UITools.IH_IMAGE_SOFT + UITools.H_LABEL);// 有底部标签
		//#endif
	}

	// //////////////////////////////vinizeng/////////////////////////////////

	/**
	 * 绘制翻页
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param pageIndex
	 *            页码索引(0,num]
	 * @param pageSum
	 *            页码总数 num
	 * @param image
	 * @param isLeft
	 *            是否需要左页显示
	 * @param isRight
	 */
	public static final void paintPage(Graphics g, int x, int y, int pageIndex, int pageSum, boolean isLeft, boolean isRight) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		Image image = null;
		// 左
		if (isLeft) {
			if (pageIndex == 0) {
				image = UIManager.IMAGE_ARR_DARK;
			} else {
				image = UIManager.IMAGE_ARR_LIGHT;
			}
			Tools.drawRegion(g, image, x - 35, y - 3, Tools.TRANS_90, Tools.LEFT_BOTTOM);
		}
		// 右
		if (isRight) {
			if (pageIndex == pageSum - 1) {
				image = UIManager.IMAGE_ARR_DARK;
			} else {
				image = UIManager.IMAGE_ARR_LIGHT;
			}
			Tools.drawRegion(g, image, x + 25, y - 3, Tools.TRANS_270, Tools.LEFT_BOTTOM);
		}
		//
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		g.drawString((pageIndex + 1) + "/" + pageSum, x, y - 3, Tools.HCENTER_BOTTOM);
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制翻页
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param pageIndex
	 * @param pageSum
	 */
	public static final void paintPage(Graphics g, int x, int y, int pageIndex, int pageSum) {
		paintPage(g, x, y, pageIndex, pageSum, true, true);
	}

	/**
	 * 
	 * 2012-3-12 上午10:50:27 绘制引导选中的地方 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @return
	 */
	public static final void paintYindaoSelPos(Graphics g, int x, int y, int w, int h) {
		int[] colors = null;
		if (UIManager.TIME % 6 < 3) {
			colors = new int[] { 0x461113, 0xe9f2e5 };
		} else {
			colors = new int[] { 0x461113, 0xf70802 };
		}
		for (int i = 0, length = colors.length; i < length; i++) {
			drawRect(g, x, y, w, h, colors[i], i);
		}
	}

	/**
	 * 绘制引导的箭头 2012-3-12 上午10:52:12 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param direction
	 *            1:左上，2左下 3 右上 4 右下
	 * @param 引导柄的长度
	 *            * num
	 */
	public static final void paintYindaoArr(Graphics g, int x, int y, int direction, int num) {
		int iw = (UIManager.IMAGE_YINDAO.getWidth() - 1);
		int iw_handler_arr = iw - 6;
		int iw_handler = (iw - 6);// 柄间距离
		int x_arr = 1;
		int y_arr = iw;
		int y_handler = 1;
		if (UIManager.TIME % 6 < 3) {
			return;
		}
		switch (direction) {
		case 1:// 左上
		{
			g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_arr, iw, iw, Tools.TRANS_270, x, y, 0);
			int tempX = x + iw_handler_arr;
			int tempY = y + iw_handler_arr;
			for (int i = 0; i < 3; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_handler, iw, iw, Tools.TRANS_H, tempX, tempY, 0);
				tempX += iw_handler;
				tempY += iw_handler;
			}
		}
			break;
		case 2: {
			int tempX = x + iw_handler_arr;
			int tempY = y - iw;
			g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_arr, iw, iw, Tools.TRANS_NONE, x, tempY, 0);
			tempY -= iw_handler_arr;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_handler, iw, iw, Tools.TRANS_NONE, tempX, tempY, 0);
				tempX += iw_handler;
				tempY -= iw_handler;
			}
		}
			break;
		case 3: {
			int tempY = y;
			int tempX = x - iw;
			g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_arr, iw, iw, Tools.TRANS_H90, tempX, tempY, 0);
			tempX -= iw_handler_arr;
			tempY = y + iw_handler_arr;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_handler, iw, iw, Tools.TRANS_NONE, tempX, tempY, 0);
				tempX -= iw_handler;
				tempY += iw_handler;
			}
		}
			break;
		case 4: {
			int tempX = x - iw;
			int tempY = y - iw;
			g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_arr, iw, iw, Tools.TRANS_H, tempX, tempY, 0);
			tempX -= iw_handler_arr;
			tempY -= iw_handler_arr;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, x_arr, y_handler, iw, iw, Tools.TRANS_V, tempX, tempY, 0);
				tempX -= iw_handler;
				tempY -= iw_handler;
			}
		}
			break;
		}
	}

	/**
	 * 绘制引导的描述 (设定了高度) 2012-3-12 上午10:52:20 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param strs
	 */
	public static final void paintYindaoDesxribe(Graphics g, int x, int y, int w, int h, String[] strs) {
		if (strs == null) {
			return;
		}
		drawFillRectAlpha(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_BACKGROUND));
		int[] colors = UIManager.getColorsWinBorder();
		for (int i = 0, length = colors.length; i < length; i++) {
			drawColorRect(g, x + i, y + i, w - (i << 1), h - (i << 1), colors[i]);
		}
		int iw = 0;
		int tempY = y;
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + iw, tempY, Tools.TRANS_HV, Tools.LEFT_TOP);
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + w - iw, tempY, Tools.TRANS_V, Tools.RIGHT_TOP);
		tempY = y + h;
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + iw, tempY, Tools.TRANS_H, Tools.LEFT_BOTTOM);
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + w - iw, tempY, Tools.TRANS_H90, Tools.RIGHT_BOTTOM);

		paintYindaoSelPos(g, x, y, w, h);
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(x, y, w + 1, h + 1);
		int iwh = colors.length;
		int tempX = x + iwh;
		tempY = y + iwh;
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		for (int i = 0, len = strs.length; i < len; i++) {
			if (strs[i] == null) {
				continue;
			}
			g.drawString(strs[i], tempX, tempY, 0);
			tempY += AbstractGameScreen.FONT_H;
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制引导的描述(未设定高度，根据字符串数组计算) 2012-3-12 上午11:09:33 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param strs
	 */
	public static final void paintYindaoDesxribe(Graphics g, int x, int y, int w, String[] strs) {
		if (strs == null) {
			return;
		}
		int h = 0;
		for (int i = 0; i < strs.length; i++) {
			if (strs[i] == null) {
				continue;
			}
			h += AbstractGameScreen.FONT_H;
		}
		h += (UIManager.getColorsSubcoatBorder().length << 1);
		paintYindaoDesxribe(g, x, y, w, h, strs);
	}

	public static final void paintYindao(Graphics g, String[] strs, int x, int y, int direction, int w, int h) {
		int ix = 20;
		int iy = 30;
		switch (direction) {
		case 1:
			paintYindaoArr(g, x, y, direction, 4);
			paintYindaoDesxribe(g, x + ix, y + iy, w, h, strs);
			break;
		case 2:
			paintYindaoArr(g, x, y, direction, 4);
			paintYindaoDesxribe(g, x + ix, y - iy - h, w, h, strs);
			break;
		case 3:
			paintYindaoArr(g, x, y, direction, 4);
			paintYindaoDesxribe(g, x - ix - w, y + iy, w, h, strs);
			break;
		case 4:
			paintYindaoArr(g, x, y, direction, 4);
			paintYindaoDesxribe(g, x - ix - w, y - iy - h, w, h, strs);
			break;
		}
	}

	public static final void paintYindao(Graphics g, String[] strs, int x, int y, int direction, int w) {
		if (strs == null) {
			return;
		}
		int h = 0;
		for (int i = 0; i < strs.length; i++) {
			if (strs[i] == null) {
				continue;
			}
			h += AbstractGameScreen.FONT_H;
		}
		h += (UIManager.getColorsSubcoatBorder().length << 1);
		paintYindao(g, strs, x, y, direction, w, h);
	}

	public static final void paintYindao(Graphics g, String[] strs, int x, int y, int w, int direction, int dw, int dh) {
		if (strs == null) {
			return;
		}
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		//
		int ix = 0;
		int iy = 0;
		switch (direction) {
		case 1:
			paintYindaoSelPos(g, x - dw - ix, y - dh - iy, dw, dh);
			paintYindao(g, strs, x, y, direction, w);
			break;
		case 2:
			paintYindaoSelPos(g, x - dw - ix, y - dh - iy, dw, dh);
			paintYindao(g, strs, x, y, direction, w);
			break;
		case 3:
			paintYindaoSelPos(g, x, y - dh - iy, dw, dh);
			paintYindao(g, strs, x, y, direction, w);
			break;
		case 4:
			paintYindaoSelPos(g, x - ix, y - iy, dw, dh);
			paintYindao(g, strs, x, y, direction, w);
			break;
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制引导 2012-4-12 上午10:14:39 venizeng
	 * 
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param infos
	 */
	public static final void paintYindao(Graphics g, String[] str, int[] infos) {
		paintYindaoTarget(g, infos[1], infos[2], infos[3], infos[4]);
		paintYindaoArrow(g, infos[0], infos[5], infos[6], infos[7], infos[8]);
		paintYindaoDescribe(g, infos[9], infos[10], infos[11], infos[12], str);
	}

	private static final int W_ARROW = 34;
	private static final int H_ARROW = 34;

	public static final int[] getYindaoPar2(int x, int y, int w, int h, int bw, int bh, String str) {
		int[] infos = new int[13];
		infos[1] = x;
		infos[2] = y;
		infos[3] = w;
		infos[4] = h;
		//
		int[] attayInfos = null;
		int[] describe = null;
		int[] dirs = new int[] { 1, 3, 7, 9 };
		for (int i = 0; i < dirs.length; i++) {
			attayInfos = getArrayInfos(dirs[i], x, y, W_ARROW, H_ARROW);
			attayInfos[2] = W_ARROW;
			attayInfos[3] = H_ARROW;
			if (attayInfos == null || attayInfos[2] == 0) {
				continue;
			}
			describe = getDescribeXYWH(dirs[i], attayInfos[0], attayInfos[1], bw, bh, str);
			if (describe != null) {
				infos[0] = dirs[i];

				infos[5] = attayInfos[0];
				infos[6] = attayInfos[1];
				infos[7] = attayInfos[2];
				infos[8] = attayInfos[3];
				//
				infos[9] = describe[0];
				infos[10] = describe[1];
				infos[11] = describe[2];
				infos[12] = describe[3];
				return infos;
			}
		}
		return null;
	}

	private static final int[] getDescribeXYWH(int type, int arrX, int arrY, int bw, int bh, String str) {
		if (arrX < 0) {
			return null;
		}
		if (arrX >= bw) {
			return null;
		}
		if (arrY < 0) {
			return null;
		}
		if (arrY >= bh) {
			return null;
		}
		int[] infos = new int[4];
		String[] strs = null;
		int x = 0;
		int y = 0;
		int w = 0;
		int h = 0;
		int w2 = 0;// 离右边框的位置
		int h2 = 0;// 离下底面的位置

		int iw = 5;
		int ih = 5;

		int gapW = 5;

		for (int i = 0; i < 5; i++) {
			switch (type) {
			case 1:// 左上
				switch (i) {// 中间
				case 0:
					w2 = bw - arrX;
					w = arrX < w2 ? arrX : w2;
					w <<= 1;
					w += (UITools.IW_RECT_CONTENT << 1);
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - (w >> 1);
					y = arrY - h;
					break;
				case 1:// 右边
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY - h;
					break;
				case 2:// 左边
					w = w2;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY - h;
					break;
				case 3:// 右中
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY - (h >> 1);
					break;
				case 4:// 右上
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY;
					break;
				}
				x += iw;
				y += ih;
				break;
			case 3:
				switch (i) {// 右边
				case 0:// 中间
					w2 = bw - arrX;
					w = arrX < w2 ? arrX : w2;
					w <<= 1;
					w += (UITools.IW_RECT_CONTENT << 1);
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - (w >> 1);
					y = arrY - h;
					break;
				case 1:// 右边
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY - h;
					break;
				case 2:// 左边
					w = w2;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY - h;
					break;
				case 3:// 左中
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY - (h >> 1);
					break;
				case 4:// 左上
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY;
					break;
				}
				x -= iw;
				y += ih;
				break;

			case 7:
				switch (i) {// 左下
				case 0:// 中间
					w2 = bw - arrX;
					w = arrX < w2 ? arrX : w2;
					w <<= 1;
					w += (UITools.IW_RECT_CONTENT << 1);
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - (w >> 1);
					y = arrY;
					break;
				case 1:// 右边
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY;
					break;
				case 2:// 左边
					w = w2;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY;
					break;
				case 3:// 右中
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY - (h >> 1);
					break;
				case 4:// 右下
					w = arrX - w;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY - h;
					break;
				}
				x += iw;
				y -= ih;
				break;
			case 9:
				switch (i) {// 中间
				case 0:// 中间
					w2 = bw - arrX;
					w = arrX < w2 ? arrX : w2;
					w <<= 1;
					w += (UITools.IW_RECT_CONTENT << 1);
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - (w >> 1);
					y = arrY;
					break;
				case 1:// 右边
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX - w;
					y = arrY;
					break;
				case 2:// 左边
					w = w2;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY;
					break;
				case 3:// 左中
					w = arrX;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY - (h >> 1);
					break;
				case 4:// 左下
					w = arrX - w;
					strs = Tools.getStrArray(str, w);
					h = strs.length * AbstractGameScreen.FONT_H + (UITools.IH_RECT_CONTENT << 1);
					//
					x = arrX;
					y = arrY - h;
					break;
				}
				x -= iw;
				y -= ih;
				break;
			}
			if (isDescribeFitfor(x, y, w, h, bw, bh)) {
				infos[0] = x;
				infos[1] = y;
				infos[2] = w;
				infos[3] = h;
				return infos;
			}
		}
		return null;
	}

	private static final boolean isDescribeFitfor(int x, int y, int w, int h, int bw, int bh) {
		if (x < 0) {
			return false;
		}
		if (y < 0) {
			return false;
		}
		if (x + w > bw) {
			return false;
		}
		if (y + h > bh) {
			return false;
		}
		return true;
	}

	private static final int[] getArrayInfos(int type, int x, int y, int w, int h) {
		int[] infos = new int[4];
		int iw = 0;
		int ih = 0;// 衔接部分
		int tempW = w + iw;
		int tempH = w + ih;
		switch (type) {
		case 1:
			infos[0] = x - tempW;
			infos[1] = y - tempH;
			break;
		case 3:
			infos[0] = x + tempW;
			infos[1] = y - tempH;
			break;
		case 7:
			infos[0] = x - tempW;
			infos[1] = y + tempH;
			break;
		case 9:
			infos[0] = x + tempW;
			infos[1] = y + tempH;
			break;
		}
		return infos;
	}

	public static final void paintYindaoTarget(Graphics g, int x, int y, int w, int h) {
		int[] colors = null;
		if (UIManager.TIME % 6 < 3) {
			colors = new int[] { 0x461113, 0xe9f2e5 };
		} else {
			colors = new int[] { 0x461113, 0xf70802 };
		}
		for (int i = 0, length = colors.length; i < length; i++) {
			UITools.drawRect(g, x, y, w, h, colors[i], i);
		}
	}

	public static final void paintYindaoArrow(Graphics g, int type, int x, int y, int w, int h) {
		int clipW = (UIManager.IMAGE_YINDAO.getWidth());// 一个图片的高度
		final int iw = 6;// 柄上移高度,保证柄能衔接
		final int ih = 6;
		final int num = 3;
		// if (UIManager.TIME % 6 < 3) {
		// return;
		// }
		int tempX = x;
		int tempY = y;
		switch (type) {
		case 1://
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, 0, 0, clipW, clipW, Tools.TRANS_H, tempX, tempY, 0);
				tempX += (clipW - iw);
				tempY += (clipW - ih);
			}
			g.drawRegion(UIManager.IMAGE_YINDAO, 0, clipW, clipW, clipW, Tools.TRANS_90, tempX, tempY, 0);
			break;
		case 3:
			tempY += 1;
			tempX -= clipW;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, 0, 0, clipW, clipW, Tools.TRANS_HV, tempX, tempY, 0);
				tempX -= (clipW - iw);
				tempY += (clipW - ih);
			}
			tempY -= 1;
			g.drawRegion(UIManager.IMAGE_YINDAO, 0, clipW, clipW, clipW, Tools.TRANS_V90, tempX, tempY, 0);
			break;
		case 7:
			tempY += 1;
			tempY -= clipW;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, 0, 0, clipW, clipW, Tools.TRANS_HV, tempX, tempY, 0);
				tempX += (clipW - iw);
				tempY -= (clipW - ih);
			}
			tempY -= 1;
			g.drawRegion(UIManager.IMAGE_YINDAO, 0, clipW, clipW, clipW, Tools.TRANS_HV, tempX, tempY, 0);
			break;
		case 9:
			tempX -= clipW;
			tempY -= clipW;
			for (int i = 0; i < num; i++) {
				g.drawRegion(UIManager.IMAGE_YINDAO, 0, 0, clipW, clipW, Tools.TRANS_270, tempX, tempY, 0);
				tempX -= (clipW - iw);
				tempY -= (clipW - ih);
			}
			g.drawRegion(UIManager.IMAGE_YINDAO, 0, clipW, clipW, clipW, Tools.TRANS_V, tempX, tempY, 0);
			break;
		}
	}

	public static final void paintYindaoDescribe(Graphics g, int x, int y, int w, int h, String[] strs) {
		if (strs == null) {
			return;
		}
		UITools.drawFillRectAlpha(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_BACKGROUND));
		int[] colors = UIManager.getColorsWinBorder();
		for (int i = 0, length = colors.length; i < length; i++) {
			UITools.drawColorRect(g, x + i, y + i, w - (i << 1), h - (i << 1), colors[i]);
		}
		int iw = 0;
		int tempY = y;
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + iw, tempY, Tools.TRANS_HV, Tools.LEFT_TOP);
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + w - iw, tempY, Tools.TRANS_V, Tools.RIGHT_TOP);
		tempY = y + h;
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + iw, tempY, Tools.TRANS_H, Tools.LEFT_BOTTOM);
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + w - iw, tempY, Tools.TRANS_H90, Tools.RIGHT_BOTTOM);

		// paintYindaoSelPos(g, x, y, w, h);
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(x, y, w + 1, h + 1);
		int iwh = colors.length;
		int tempX = x + iwh;
		tempY = y + iwh;
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		for (int i = 0, len = strs.length; i < len; i++) {
			if (strs[i] == null) {
				continue;
			}
			g.drawString(strs[i], tempX, tempY, 0);
			tempY += AbstractGameScreen.FONT_H;
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	public static final void paintEquipBar(Graphics g, int x, int y, ActorItem item, boolean isSel, boolean isFocused, boolean isOpen, int pos) {
		int picX = pos * 16;
		int picY = 0;
		if (item == null) {
			Image image_bottom = isOpen ? UIManager.IMAGE_ITEM_OPEN : UIManager.IMAGE_ITEM_CLOSE;
			g.drawImage(image_bottom, x, y, 0);
			g.setColor(Tools.WHITE);
			g.drawRegion(UIManager.IMAGE_BAG_WORDS, picX, picY, 16, 16, Tools.TRANS_NONE, x + ((UITools.W_BAG - 16) >> 1), y + ((UITools.H_BAG - 16) >> 1), 0);
			if (isFocused) {
				UITools.paintFocusBox(g, x, y, UITools.W_BAG, UITools.H_BAG);
			} else if (isSel) {
				UITools.paintSelItem(g, x, y, UITools.W_BAG, UITools.H_BAG);
			}
		} else {
			UITools.paintActorItem(g, x, y, item, false, isFocused, true);
		}
	}

	/**
	 * 绘制道具并将道具绘制到格子中,默认为非聚焦，非选中，開啟狀態
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param item
	 * @param isOpen
	 */
	public static final void paintActorItem(Graphics g, int x, int y, ActorItem item) {
		paintActorItem(g, x, y, item, false, false, true);
	}

	/**
	 * 绘制道具并将道具绘制到格子中,默认为非聚焦，非选中
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param item
	 * @param isOpen
	 */
	public static final void paintActorItem(Graphics g, int x, int y, ActorItem item, boolean isOpen) {
		paintActorItem(g, x, y, item, false, false, isOpen);
	}

	/**
	 * 绘制道具
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param image
	 * @param item
	 * @param isSel
	 *            是否選中（非聚焦）
	 * @param isFocused
	 *            聚焦狀態下
	 * @param isOpen
	 *            是否开启
	 */
	public static final void paintActorItem(Graphics g, int x, int y, ActorItem item, boolean isSel, boolean isFocused, boolean isOpen) {
		Image image_bottom = isOpen ? UIManager.IMAGE_ITEM_OPEN : UIManager.IMAGE_ITEM_CLOSE;
		g.drawImage(image_bottom, x, y, 0);
		if (item != null) {
			item.drawIcon(g, x + 1, y + 1, 0);
		}
		if (isFocused) {
			paintFocusBox(g, x, y, W_BAG, H_BAG);
		} else if (isSel) {
			paintSelItem(g, x, y, W_BAG, H_BAG);
		}
	}

	private static final int IW_MONEY_YINPIAO = 2;// 数字与金钱的间隙

	/**
	 * 银票， 2012-3-16 上午10:10:21 venizeng
	 * 
	 * @param g
	 * @param x
	 *            右锚点
	 * @param y
	 *            底部锚点
	 */
	public static final void paintMoneyYinpiaoRB(Graphics g, int x, int y, long money, boolean isSel) {
		if (isSel) {
			paintMoneySel(g, x - W_MONEY_YINPIAO, y - H_MONEY_YINPIAO, W_MONEY_YINPIAO, H_MONEY_YINPIAO);
		}
		x -= UITools.IW_RECT_CONTENT;
		y -= UITools.IH_RECT_CONTENT;
		g.drawImage(UIManager.IMAGE_YINPIAO, x, y, Tools.RIGHT_BOTTOM);
		Tools.drawNumber(g, GameScene.s_img_num, x - IW_MONEY_YINPIAO - UIManager.IMAGE_YINPIAO.getWidth(), y, W_NUM, H_NUM, money, 0, Tools.RIGHT_BOTTOM, false);
	}
	
	public static final void paintMoneyYinpiaoRB(Graphics g, int x, int y, long money, boolean isSel,String temp,int yanseli,int yansewai) {
		if (isSel) {
			paintMoneySel(g, x - W_MONEY_YINPIAO, y - H_MONEY_YINPIAO, W_MONEY_YINPIAO, H_MONEY_YINPIAO);
		}
		x -= UITools.IW_RECT_CONTENT;
		y -= UITools.IH_RECT_CONTENT;
		if( temp != null ){
			int width = AbstractGameScreen.s_font.stringWidth(temp);
			Tools.drawString(g, yanseli, yansewai, temp, x-width, y+2, Tools.RIGHT_BOTTOM);
		}
		g.drawImage(UIManager.IMAGE_YINPIAO, x, y, Tools.RIGHT_BOTTOM);
		Tools.drawNumber(g, GameScene.s_img_num, x - IW_MONEY_YINPIAO - UIManager.IMAGE_YINPIAO.getWidth(), y, W_NUM, H_NUM, money, 0, Tools.RIGHT_BOTTOM, false);
	}

	public static final void paintMoneyYinpiaoLB(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyYinpiaoRB(g, x + W_MONEY_YINPIAO, y, money, isSel);
	}

	public static final void paintMoneyYinpiaoLT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyYinpiaoRB(g, x + W_MONEY_YINPIAO, y + H_MONEY_YINPIAO, money, isSel);
	}

	public static final void paintMoneyYinpiaoRT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyYinpiaoRB(g, x, y + H_MONEY_YINPIAO, money, isSel);
	}

	public static final void paintMoneyZhangongRB(Graphics g, int x, int y, long money, boolean isSel) {
		if (isSel) {
			paintMoneySel(g, x - W_MONEY_ZHANGONG, y - H_MONEY_ZHANGONG, W_MONEY_ZHANGONG, H_MONEY_ZHANGONG);
		}
		x -= UITools.IW_RECT_CONTENT;
		y -= UITools.IH_RECT_CONTENT;
		g.drawImage(UIManager.IMAGE_ZHANGONG, x, y, Tools.RIGHT_BOTTOM);
		Tools.drawNumber(g, GameScene.s_img_num, x - IW_MONEY_YINPIAO - UIManager.IMAGE_ZHANGONG.getWidth(), y, W_NUM, H_NUM, money, 0, Tools.RIGHT_BOTTOM, false);
	}
	
	public static final void paintMoneyJiagongRB(Graphics g, int x, int y, long money, boolean isSel) {
		if (isSel) {
			paintMoneySel(g, x - W_MONEY_JIAGONG, y - H_MONEY_JIAGONG, W_MONEY_JIAGONG, H_MONEY_JIAGONG);
		}
		x -= UITools.IW_RECT_CONTENT;
		y -= UITools.IH_RECT_CONTENT;
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		g.drawString(GONGXIAN,x, y, Tools.RIGHT_BOTTOM);
		Tools.drawNumber(g, GameScene.s_img_num, x - IW_MONEY_YINPIAO - W_MONEY_JIAGONG, y, W_NUM, H_NUM, money, 0, Tools.RIGHT_BOTTOM, false);
	}

	private static final int getMoneyZhangongWidth() {
		return 5 * W_NUM + IW_MONEY_YINPIAO + UIManager.IMAGE_ZHANGONG.getWidth() + (UITools.IW_RECT_CONTENT << 1);
	}
	
	private static final int getMoneyYinpiaoWidth() {
		return 5 * W_NUM + IW_MONEY_YINPIAO + UIManager.IMAGE_YINPIAO.getWidth() + (UITools.IW_RECT_CONTENT << 1);
	}

	private static final int getMoneyYinpiaoHeight() {
		return UIManager.IMAGE_YINPIAO.getHeight() + (UITools.IW_RECT_CONTENT << 1);
	}
	
	private static final int getMoneyZhangongHeight() {
		return UIManager.IMAGE_ZHANGONG.getHeight() + (UITools.IW_RECT_CONTENT << 1);
	}

	public static final void paintMoneyRmbRB(Graphics g, int x, int y, long money, boolean isSel) {
		if (isSel) {
			paintMoneySel(g, x - W_MONEY_RMB, y - H_MONEY_RMB, W_MONEY_RMB, H_MONEY_RMB);
		}
		x -= UITools.IW_RECT_CONTENT;
		y -= UITools.IH_RECT_CONTENT;
		g.drawImage(UIManager.IMAGE_MONEY_RMB, x, y, Tools.RIGHT_BOTTOM);
		Tools.drawNumber(g, GameScene.s_img_num, x - IW_MONEY_YINPIAO - UIManager.IMAGE_MONEY_RMB.getWidth(), y, W_NUM, H_NUM, money, 0, Tools.RIGHT_BOTTOM, false);
	}

	public static final void paintMoneyRmbLB(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyRmbRB(g, x + W_MONEY_RMB, y, money, isSel);
	}

	public static final void paintMoneyRmbLT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyRmbRB(g, x + W_MONEY_RMB, y + H_MONEY_RMB, money, isSel);
	}

	public static final void paintMoneyRmbRT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyRmbRB(g, x, y + H_MONEY_RMB, money, isSel);
	}

	private static final int getMoneyRmbWidth() {
		return 5 * W_NUM + IW_MONEY_YINPIAO + UIManager.IMAGE_YINPIAO.getWidth() + (UITools.IW_RECT_CONTENT << 1);
	}

	private static final int getMoneyRmbHeight() {
		return UIManager.IMAGE_MONEY_RMB.getHeight() + (UITools.IW_RECT_CONTENT << 1);
	}

	/**
	 * @param g
	 * @param x
	 * @param y
	 * @param money_rmb
	 * @param rmb
	 * @param rectW
	 */
	private static final void paintMoneyRmb(Graphics g, int x, int y, long money_rmb, Image rmb, int rectW) {
		int tempX = 0;
		int anchor = 0;
		if (rectW == 0) {
			tempX = x + IW_RECT_CONTENT;
			anchor = Graphics.TOP | Graphics.LEFT;
			int digit = Tools.getNumberLongOF(money_rmb);
			Tools.drawNumber(g, GameScene.s_img_num, tempX, y, 5, 7, money_rmb, 0, anchor, false);
			g.drawImage(rmb, tempX + IW_RECT_CONTENT + digit * 5, y, 0);
		} else {
			tempX = x + rectW - rmb.getWidth();
			anchor = Graphics.TOP | Graphics.RIGHT;
			g.drawImage(rmb, tempX, y, 0);
			Tools.drawNumber(g, GameScene.s_img_num, tempX - IW_RECT_CONTENT, y, 5, 7, money_rmb, 0, anchor, false);
		}
	}

	/**
	 * 图片固定画在区域后
	 * 
	 */
	public static final void paintMoneyRmb(Graphics g, int x, int y, long money_rmb, int rectW) {
		paintMoneyRmb(g, x, y, money_rmb, UIManager.IMAGE_MONEY_RMB, rectW);
	}

	/**
	 * 绘制人民币 2012-2-14 下午03:12:09 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money_rmb
	 * @param rmb
	 */
	public static final void paintMoneyRmb(Graphics g, int x, int y, long money_rmb, boolean isSel) {
		if (isSel) {
			int w = 115;
			g.setColor(UIManager.getPaletteColor(UIManager.COLOR_MONEYGAME_SEL));
			g.fillRect(x - w, y, w, UIManager.IMAGE_MONEY_RMB.getHeight());
		}
		Tools.drawNumber(g, GameScene.s_img_num, x - UIManager.IMAGE_MONEY_RMB.getWidth() - 2, y, 5, 7, money_rmb, 0, Tools.RIGHT_TOP, false);
		g.drawImage(UIManager.IMAGE_MONEY_RMB, x, y, Tools.RIGHT_TOP);
	}

	/**
	 * 绘制人民币 2012-2-14 下午03:32:28 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money_rmb
	 */
	public static final void paintMoneyRmb(Graphics g, int x, int y, long money_rmb) {
		paintMoneyRmb(g, x, y, money_rmb, false);
	}

	public static final int W_NUM = 5;// 图片字的宽度
	public static final int H_NUM = 7;// 图片字的高度
	private static final int IW_MONEY_GAME = 2; // 游戏币，金银铜之间的间距
	private static final int IW_MONEY_GAME_IMAGE = 1; // 游戏币，金银铜与金币，银币等之间的间距
	private static final int MAXW_MONEY_GAME_COPPER_SILVER = W_NUM << 1;// 最大铜币和银币宽度
	private static final int MAXW_MONEY_GAME_GOLD = W_NUM * 6;// 最大金币宽度

	/**
	 * 绘制金钱被选中的情况 2012-3-19 下午03:26:47 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	private static void paintMoneySel(Graphics g, int x, int y, int w, int h) {
		UITools.fillContentRect(g, x, y, w, h, 0x7739729);
	}

	/**
	 * 绘制游戏币 锚点：右下 2012-3-19 下午01:19:47 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money
	 * @param isSel
	 */
	public static final void paintMoneyGameRB(Graphics g, int x, int y, long money, boolean isSel) {
		int w = getMoneyGameWidth();
		int tempX = x;
		int tempY = y;
		if (isSel) {
			paintMoneySel(g, tempX - w, tempY - H_MONEY_GAME, w, UITools.H_MONEY_GAME);
		}
		//
		tempX -= UITools.IW_RECT_CONTENT;
		tempY -= UITools.IH_RECT_CONTENT;
		// 铜
		g.drawImage(UIManager.IMAGE_MONEY_COPPER, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_COPPER.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameCopper(money), 0, Tools.RIGHT_BOTTOM, false);
		tempX -= (MAXW_MONEY_GAME_COPPER_SILVER + IW_MONEY_GAME);
		//
		g.drawImage(UIManager.IMAGE_MONEY_SILVER, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_SILVER.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameSilver(money), 0, Tools.RIGHT_BOTTOM, false);
		tempX -= (MAXW_MONEY_GAME_COPPER_SILVER + IW_MONEY_GAME);
		//
		g.drawImage(UIManager.IMAGE_MONEY_GOLD, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_GOLD.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameGold(money), 0, Tools.RIGHT_BOTTOM, false);
	}
	
	public static final void paintMoneyGameRB(Graphics g, int x, int y, long money, boolean isSel,String temp,int yanseli,int yansewai) {
		int w = getMoneyGameWidth();
		int tempX = x;
		int tempY = y;
		if (isSel) {
			paintMoneySel(g, tempX - w, tempY - H_MONEY_GAME, w, UITools.H_MONEY_GAME);
		}
		//
		tempX -= UITools.IW_RECT_CONTENT;
		tempY -= UITools.IH_RECT_CONTENT;
		// 铜
		g.drawImage(UIManager.IMAGE_MONEY_COPPER, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_COPPER.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameCopper(money), 0, Tools.RIGHT_BOTTOM, false);
		tempX -= (MAXW_MONEY_GAME_COPPER_SILVER + IW_MONEY_GAME);
		//
		g.drawImage(UIManager.IMAGE_MONEY_SILVER, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_SILVER.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameSilver(money), 0, Tools.RIGHT_BOTTOM, false);
		tempX -= (MAXW_MONEY_GAME_COPPER_SILVER + IW_MONEY_GAME);
		//
		g.drawImage(UIManager.IMAGE_MONEY_GOLD, tempX, tempY, Tools.RIGHT_BOTTOM);
		tempX -= (UIManager.IMAGE_MONEY_GOLD.getWidth() + IW_MONEY_GAME_IMAGE);
		Tools.drawNumber(g, GameScene.s_img_num, tempX, tempY, W_NUM, H_NUM, ActorRole.getMoneyGameGold(money), 0, Tools.RIGHT_BOTTOM, false);
	     
		if( temp != null ){
			int width = AbstractGameScreen.s_font.stringWidth(temp);
			Tools.drawString(g, yanseli, yansewai, temp, tempX-width, tempY+2, Tools.RIGHT_BOTTOM);
		}
	}

	/**
	 * 绘制游戏币 锚点：右上 2012-3-19 下午01:19:02 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money
	 * @param isSel
	 */
	public static final void paintMoneyGameRT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyGameRB(g, x, y + H_MONEY_GAME, money, isSel);
	}

	/**
	 * 绘制游戏币 锚点：左下 2012-3-19 下午01:19:23 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money
	 * @param isSel
	 */
	public static final void paintMoneyGameLB(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyGameRB(g, x + getMoneyGameWidth(), y, money, isSel);
	}

	/**
	 * 绘制游戏币 锚点：左上 2012-3-19 下午01:19:27 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money
	 * @param isSel
	 */
	public static final void paintMoneyGameLT(Graphics g, int x, int y, long money, boolean isSel) {
		paintMoneyGameRB(g, x + getMoneyGameWidth(), y + H_MONEY_GAME, money, isSel);
	}

	/**
	 * 获得游戏币高度 2012-3-19 下午01:18:29 venizeng
	 * 
	 * @return
	 */
	private static final int getMoneyGameHeight() {
		return UIManager.IMAGE_MONEY_GOLD.getHeight() + (UITools.IH_RECT_CONTENT << 1);
	}

	/**
	 * 获得游戏币宽度 2012-3-19 下午01:18:29 venizeng
	 * 
	 * @return
	 */
	private static final int getMoneyGameWidth() {
		int w_gold = UIManager.IMAGE_MONEY_GOLD.getWidth();
		int w_silver = UIManager.IMAGE_MONEY_SILVER.getWidth();
		int w_copper = UIManager.IMAGE_MONEY_COPPER.getWidth();
		int w = w_gold + w_silver + w_copper + IW_MONEY_GAME * 2 + IW_MONEY_GAME_IMAGE * 3 + MAXW_MONEY_GAME_GOLD + MAXW_MONEY_GAME_COPPER_SILVER * 2
				+ (UITools.IW_RECT_CONTENT << 1);
		return w;
	}

	/**
	 * 绘制游戏币 2012-2-14 下午03:32:38 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money
	 * @param isSel
	 *            是否被选中
	 */
	public static final void paintMoneyGame(Graphics g, int x, int y, long money, boolean isSel) {
		if (isSel) {
			g.setColor(UIManager.getPaletteColor(UIManager.COLOR_MONEYGAME_SEL));
			g.fillRect(x - 35, y - 1, getMoneyGameWidth(), H_MONEY_GAME);
		}
		paintMoneyGame(g, x, y, money, UIManager.IMAGE_MONEY_GOLD, UIManager.IMAGE_MONEY_SILVER, UIManager.IMAGE_MONEY_COPPER);
	}

	/**
	 * 绘制只有金币的游戏币 2012-2-14 下午03:41:01
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money_rmb
	 * @param rectW
	 */
	public static final void paintMoneyGameGold(Graphics g, int x, int y, long money_rmb, int rectW) {

		int tempX = 0;
		int anchor = 0;
		if (rectW == 0) {
			tempX = x + IW_RECT_CONTENT;
			anchor = Graphics.TOP | Graphics.LEFT;
			int digit = Tools.getNumberLongOF(money_rmb);
			Tools.drawNumber(g, GameScene.s_img_num, tempX, y, 5, 7, (int) money_rmb, 0, anchor, false);
			g.drawImage(UIManager.IMAGE_MONEY_GOLD, tempX + IW_RECT_CONTENT + digit * 5, y, 0);
		} else {
			tempX = x + rectW - UIManager.IMAGE_MONEY_RMB.getWidth();
			anchor = Graphics.TOP | Graphics.RIGHT;
			g.drawImage(UIManager.IMAGE_MONEY_GOLD, tempX + ((UIManager.IMAGE_MONEY_RMB.getWidth() - UIManager.IMAGE_MONEY_GOLD.getWidth()) >> 1), y, 0);
			Tools.drawNumber(g, GameScene.s_img_num, tempX - IW_RECT_CONTENT, y, 5, 7, money_rmb, 0, anchor, false);
		}
	}

	/**
	 * venizeng 绘制游戏币
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param money_game
	 */
	private static final void paintMoneyGame(Graphics g, int x, int y, long money, Image image_gold, Image image_silver, Image ton) {
		int tempX = x;
		Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7, ActorRole.getMoneyGameGold(money), 0, Tools.RIGHT_TOP, false);
		// Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7,
		// ActorRole
		// .getMoneyGameGold(money), 0, anchor2, false);
		g.drawImage(image_gold, tempX, y, Tools.LEFT_TOP);

		tempX += 25;
		Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7, ActorRole.getMoneyGameSilver(money), 0, Tools.RIGHT_TOP, false);
		// Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7,
		// ActorRole
		// .getMoneyGameSilver(money), 0, anchor2, false);
		g.drawImage(image_gold, tempX, y, Tools.LEFT_TOP);

		tempX += 25;
		Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7, ActorRole.getMoneyGameCopper(money), 0, Tools.RIGHT_TOP, false);
		// Tools.drawNumber(g, GameScene.s_img_num, tempX - 2, y, 5, 7,
		// ActorRole
		// .getMoneyGameCopper(money), 0, anchor2, false);
		g.drawImage(image_gold, tempX, y, Tools.LEFT_TOP);

	}

	/**
	 * 绘制焦点状态下的显示效果
	 * 
	 * @param g
	 * @param img
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void paintFocusBox(Graphics g, int x, int y, int w, int h) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		int FIXNUM = 7;
		int num = UIManager.TIME % FIXNUM;
		int halfNum = (FIXNUM >> 1);
		if (num > halfNum) {
			num = FIXNUM - num - 1;
		}
		drawImageSelectBox(g, x - num, y - num, w + (num << 1), h + (num << 1));
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 选中状态下的显示 非聚焦状态下
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void paintSelItem(Graphics g, int x, int y, int w, int h) {
		drawRect(g, x, y, w, h, 0x0, 0);
		drawRect(g, x, y, w, h, Tools.YELLOW, 1);
		drawRect(g, x, y, w, h, Tools.YELLOW, 2);
	}

	/**
	 * 界面中绘制内容框的方法 空心框
	 * 
	 * @2012-2-14 下午03:47:05 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void paintContentRect(Graphics g, int x, int y, int w, int h) {
		int[] colors = UIManager.getColorsSubcoatBorder();
		for (int i = 0, length = colors.length; i < length; i++) {
			drawRect(g, x, y, w, h, colors[i], i);
		}
	}

	/**
	 * 绘制内容框，多用于列表
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 *            单元行宽
	 * @param h_row
	 *            单元行高
	 * @param num
	 *            具有多少行
	 */
	public static final void paintContentRect(Graphics g, int x, int y, int w, int h_row, int num) {
		int tempH = h_row * num + (UIManager.getColorsSubcoatBorder().length << 1);
		paintContentRect(g, x, y, w, tempH);
	}

	/**
	 * 内容框 - 实心 多用於需要在框上多覆蓋一層的情況
	 * 
	 * @2012-2-21 上午09:03:23 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param innerColor
	 */
	public static void fillContentRect(Graphics g, int x, int y, int w, int h, int innerColor) {
		paintContentRect(g, x, y, w, h);
		fillRect(g, x, y, w, h, innerColor, 3);
	}

	/**
	 * 无内容的输入框
	 * 
	 * @2012-2-14 下午03:48:19 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param isSel
	 */
	public static final void paintInputRect(Graphics g, int x, int y, int w, int h, boolean isSel) {
		paintInputRect(g, x, y, w, h, null, isSel);
	}

	/**
	 * 有内容的输入框
	 * 
	 * @2012-2-15 上午11:39:18 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isSel
	 *            是否选中
	 */
	public static final void paintInputRect(Graphics g, int x, int y, int w, int h, String str, boolean isSel) {
		if (isSel) {
			fillContentRect(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_RECT_SEL));
		} else {
			paintContentRect(g, x, y, w, h);
		}
		if (str == null || str.equals("")) {
			return;
		}
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		UITools.paintScrollStr(g, x + UITools.IW_RECT_CONTENT, y + UITools.IH_RECT_CONTENT, w - (IW_RECT_CONTENT << 1), h - IH_RECT_CONTENT << 1, str);
	}

	/**
	 * 输入框文字左对齐 2012-3-1 下午01:38:30 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isSel
	 */
	public static final void paintInputRectLT(Graphics g, int x, int y, int w, int h, String str, boolean isSel) {
		if (isSel) {
			fillContentRect(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_RECT_SEL));
		} else {
			paintContentRect(g, x, y, w, h);
		}
		if (str == null || str.equals("")) {
			return;
		}
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		int iw = UIManager.getColorsSubcoatBorder().length;
		g.setClip(x + iw, y + iw, w - (iw << 1) + 1, h - (iw << 1) + 1);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		int tempX = x + UITools.IW_RECT_CONTENT;
		int tempY = y + ((h - AbstractGameScreen.FONT_H) >> 1);
		int sw = AbstractGameScreen.s_font.stringWidth(str);
		if (sw > w - (iw << 1)) {
			sw += 2;
			tempX -= UIManager.TIME % sw;
			g.drawString(str, tempX, tempY, Tools.LEFT_TOP);
			g.drawString(str, tempX + sw, tempY, Tools.LEFT_TOP);
		} else {

			g.drawString(str, tempX, tempY, Tools.LEFT_TOP);
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 有内容的输入框
	 * 
	 * @2012-2-15 上午11:39:18 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isSel
	 *            是否选中
	 */
	public static final void paintInputRect(Graphics g, int x, int y, int w, String str, boolean isSel) {
		paintInputRect(g, x, y, w, H_LABEL_STR, str, isSel);
	}

	/**
	 * 输入带有文字的内容框，其中文字颜色及内框颜色可定制 @ 2012-2-21 上午11:01:21 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color_rect
	 * @param str_col
	 *            -1 则不绘制
	 * @param content
	 */
	public static final void paintRectStr(Graphics g, int x, int y, int w, int h, int color_rect, int str_col, String content) {
		fillContentRect(g, x, y, w, h, color_rect);
		if (content == null || content.equals("")) {
			return;
		}
		g.setColor(str_col);
		g.drawString(content, x + (w >> 1), y + ((h - AbstractGameScreen.FONT_H) >> 1), Tools.HCENTER_TOP);
	}

	/**
	 * 绘制带框多行文字 文字左对齐 每行文字垂直居中 2012-3-1 上午11:24:29 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h_row
	 *            一行显示的高度
	 * @param color_rect
	 * @param str_col
	 * @param content
	 */
	public static final void paintRectStr(Graphics g, int x, int y, int w, int h_row, int color_rect, int str_col, String[] content) {
		if (content == null) {
			return;
		}
		int h = content.length * h_row + (IH_RECT_CONTENT << 1);
		fillContentRect(g, x, y, w, h, color_rect);
		g.setColor(str_col);
		int tempX = x + IW_RECT_CONTENT;
		int tempY = y + IH_RECT_CONTENT + ((h - h_row) >> 1);
		for (int i = 0, length = content.length; i < length; i++) {
			if (content[i] != null) {
				g.drawString(content[i], tempX, tempY, Tools.LEFT_TOP);
			}
			tempY += h_row;
		}
	}

	/**
	 * 繪製標題 2012-2-20 下午07:56:22 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param content
	 */
	public static void paintTitle(Graphics g, int x, int y, int w, int h, String content) {
		paintRectStr(g, x, y, w, h, UIManager.getPaletteColor(UIPalette.COLOR_TITLE), UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS), content);
	}

	/**
	 * 繪製標題 - 具有默认高度
	 * 
	 * @2012-2-20 下午07:56:22 venizeng
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param content
	 */
	public static void paintTitle(Graphics g, int x, int y, int w, String content) {
		paintRectStr(g, x, y, w, H_LABEL_STR, UIManager.getPaletteColor(UIPalette.COLOR_TITLE), UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS), content);
	}

	/**
	 * 滚动条,此处是在不影响原有系统中使用 2012-2-14 下午03:58:44 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param h
	 * @param plan
	 */
	public static final void paintScrollBar(Graphics g, int x, int y, int h, int plan) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		drawScrollBar(g, x, y, h, plan);
		g.setClip(clipX, clipY, clipW, clipH);
	}

	public static int getDragX(int x, int w) {
		return x + w - UIManager.getColorsWinBorder().length - UIManager.IMAGE_SCROLL_ARR.getWidth();
	}

	/**
	 * 绘制带边框的人物动画
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param anim
	 * @param actionId
	 * @param frameIndex
	 */
	public static final void paintAnim(Graphics g, int x, int y, Animation anim, int actionId, int frameIndex) {
		paintAnim(g, x, y, W_ANIM, W_ANIM, anim, actionId, frameIndex);
	}

	public static final void paintAnim(Graphics g, int x, int y, int w, int h, Animation anim, int actionId, int frameIndex) {
		paintContentRect(g, x, y, w, h);
		if (anim == null) {
			return;
		}
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		anim.draw(g, x + (w >> 1), y + h - 3, false, false, anim.m_actions[actionId][frameIndex] & 0x03FF);
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制背景
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 */
	public static final void paintBackGround(Graphics g, int x, int y, int w, int h, String title) {
		paintBackGround(g, x, y, w, h, title, true, true);
	}

	/**
	 * 绘制背景 2012-2-20 上午09:34:16 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 * @param _isLeft
	 *            是否支持左标签
	 * @param _isRight
	 */
	public static final void paintBackGround(Graphics g, int x, int y, int w, int h, String title, boolean _isLeft, boolean _isRight) {
		paintBackGround(g, x, y, w, h, title, null, _isLeft, _isRight);
	}

	/**
	 * 绘制大界面 2012-4-10 下午06:06:29 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 * @param describe
	 * @param _isLeft
	 * @param _isRight
	 */
	public static final void paintBackGround(Graphics g, int x, int y, int w, int h, String title, String describe, boolean _isLeft, boolean _isRight) {
		// 绘制背景
		drawWindowBackgroud(g, x, y, w, h);
		// #if screen == "320240"
		// # paintBackgroundTitleOn320240(g, x - UIManager.IMAGE_TITlE_SMALL.getHeight(), y, UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, title);
		// # paintBackgroundTitleOn320240(g, x + w, y, UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, describe);
		// # paintBackgroundButtonOn320240(g, x, y, w, h);
		// #else
		paintBackgroundTitleOn240320(g, x, y, w, h, title); // 绘制标题
		paintBackgroundButton(g, x, y, w, h, _isLeft, _isRight);// 绘制按钮
		paintBackgroundDescribe(g, x, y, w, h, describe);
		//#endif
	}

	/**
	 * 绘制背景标题,适用于所有机型 2012-4-9 下午01:11:40 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 */
	public static final void paintBackgroundTitle(Graphics g, int x, int y, int w, int h, String title) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		title = title == null ? "" : title;
		drawTitle(g, title, x, y, w, h);
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 仅适合于顶部绘制标题的情况 2012-4-10 下午06:37:33 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 */
	public static final void paintBackgroundTitleOn240320(Graphics g, int x, int y, int w, int h, String title) {
		g.setClip(x, y, w, h);
		int midLen = w - (UIManager.IMAGE_TITlE_SMALL.getWidth() << 1);
		if (midLen > 0) {
			int midAmount = midLen / UIManager.IMAGE_TITlE_MIDDLE.getWidth() + 1;
			for (int i = 0; i < midAmount; i++) {
				g.drawImage(UIManager.IMAGE_TITlE_MIDDLE, x + UIManager.IMAGE_TITlE_SMALL.getWidth() + i * UIManager.IMAGE_TITlE_MIDDLE.getWidth(), y, Tools.LEFT_TOP);
			}
		}
		g.drawImage(UIManager.IMAGE_TITlE_SMALL, x, y, Tools.LEFT_TOP);
		Tools.drawRegion(g, UIManager.IMAGE_TITlE_SMALL, x + w - UIManager.IMAGE_TITlE_SMALL.getWidth(), y, Tools.TRANS_H, Tools.LEFT_TOP);
		drawColorString(g, title, x + (w >> 1), y + ((UIManager.IMAGE_TITlE_SMALL.getHeight() - AbstractGameScreen.FONT_H) >> 1), Tools.WHITE, Tools.HCENTER_TOP);
	}

	/**
	 * 绘制左右软件按钮 2012-4-10 下午06:38:23 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void paintBackgroundButtonOn320240(Graphics g, int x, int y, int w, int h) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		int tempY = y + h - UITools.H_LABEL;
		paintLabelImage(g, x - UIManager.IMAGE_TITlE_SMALL.getHeight(), tempY, UIManager.IMAGE_TITlE_SMALL.getHeight(), UITools.H_LABEL, UIManager.IMAGE_GOU, true);
		paintLabelImage(g, x + w, tempY, UIManager.IMAGE_TITlE_SMALL.getHeight(), UITools.H_LABEL, UIManager.IMAGE_CHA, true);
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 
	 * 2012-4-9 下午03:28:53 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param title
	 */
	public static final void paintBackgroundTitleOn320240(Graphics g, int x, int y, int h, String title) {
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		Tools.drawRegion(g, UIManager.IMAGE_TITlE_SMALL, x, y, Tools.TRANS_270, Tools.LEFT_TOP);
		Tools.drawRegion(g, UIManager.IMAGE_TITlE_SMALL, x, y + h, Tools.TRANS_V90, Tools.LEFT_BOTTOM);
		int sumH = UIManager.IMAGE_TITlE_SMALL.getWidth() << 1;
		if (sumH <= h) {
			sumH = h - sumH;
			int h_mid = UIManager.IMAGE_TITlE_MIDDLE.getWidth();
			int num = (sumH + h_mid - 1) / h_mid;
			int tempY = y + UIManager.IMAGE_TITlE_SMALL.getWidth();
			for (int i = 0; i < num; i++) {
				Tools.drawRegion(g, UIManager.IMAGE_TITlE_MIDDLE, x, tempY, Tools.TRANS_270, Tools.LEFT_TOP);
				tempY += h_mid;
			}

			if (title != null) {
				g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS));
				char[] chars = title.toCharArray();
				sumH = chars.length * AbstractGameScreen.FONT_H;
				int tempX = x + ((UIManager.IMAGE_TITlE_SMALL.getHeight() - AbstractGameScreen.s_font.charWidth('中')) >> 1);
				tempY = y + ((h - sumH) >> 1);
				for (int i = 0; i < chars.length; i++) {
					g.drawChar(chars[i], tempX, tempY, 0);
					tempY += AbstractGameScreen.FONT_H;
				}
			}
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制界面描述 2012-4-9 下午05:18:25 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param string
	 */
	private static void paintBackgroundDescribe(Graphics g, int x, int y, int w, int h, String string) {
		if (string == null) {
			return;
		}
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS));
		g.drawString(string, AbstractGameScreen.SCREEN_WIDTH >> 1, y + h - UITools.IH_RECT_CONTENT, Tools.HCENTER_BOTTOM);
	}

	/**
	 * 绘制背景按钮 2012-4-9 下午01:11:53 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param _isLeft
	 * @param _isRight
	 */
	public static final void paintBackgroundButton(Graphics g, int x, int y, int w, int h, boolean _isLeft, boolean _isRight) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		int tempY = y + h - H_LABEL - IH_IMAGE_SOFT;
		int tempY = AbstractGameScreen.SCREEN_HEIGHT - H_LABEL - 1;//- IH_IMAGE_SOFT;
		
		if (_isLeft) {
			UITools.paintLabelImage(g, 0, tempY, W_LABEL_BIG, H_LABEL, UIManager.IMAGE_BUTTON_QUEDING, true);
//			UITools.paintLabelImage(g, x + IW_IMAGE_SOFT, tempY, W_LABEL_BIG, H_LABEL, UIManager.IMAGE_BUTTON_QUEDING, true);
		}
		if (_isRight) {
			UITools.paintLabelImage(g, AbstractGameScreen.SCREEN_WIDTH - W_LABEL_BIG -1, tempY, W_LABEL_BIG, H_LABEL, UIManager.IMAGE_BUTTON_FANHUI, true);
//			UITools.paintLabelImage(g, x + w - W_LABEL_BIG - IW_IMAGE_SOFT -1, tempY, W_LABEL_BIG, H_LABEL, UIManager.IMAGE_BUTTON_FANHUI, true);
		}
	}

	/**
	 * 绘制边角修饰 2012-3-1 上午10:36:30 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void paintBorderConer(Graphics g, int x, int y, int w, int h) {
		int iw = 0;
		int tempY = y + h;
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + iw, tempY, Tools.TRANS_H, Tools.LEFT_BOTTOM);
		Tools.drawRegion(g, UIManager.IMAGE_BORDER_CORNER, x + w - iw, tempY, Tools.TRANS_H90, Tools.RIGHT_BOTTOM);
	}

	/**
	 * 检查输入的金钱数据是否合法
	 * 
	 * @param money
	 * @return
	 */
	public static final int checkMoney(String money) {
		int temp = 0;
		if (money.equals("")) {
			return 0;// 0
		}
		try {
			temp = (short) Integer.parseInt(money);
		} catch (Exception e) {
			temp = -1;// 数据错误
		}
		if (temp < 0) {
			temp = -2;// 负数
		}
		return temp;
	}

	/**
	 * 绘制一个标签
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param isLi
	 *            是否选中
	 */
	public static final void paintLabel(Graphics g, int x, int y, int w, int h, boolean isSel) {
		if (isSel) {
			paintLabel(g, x, y, w, h, 0x180100, 0xe0e16a, 0x461a17, 0xb6554d, 0x92422e, 0x753c2e, 0xa768768);
		} else {
			paintLabel(g, x, y, w, h, 0x230200, 0xd5c181, 0x685a4b, 0xdb867b, 0xb37868, 0x91685e, 0x4473218);
		}
	}

	/**
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color1
	 * @param color2
	 * @param color3
	 * @param color4
	 * @param color5
	 * @param color6
	 * @param color7
	 */
	private static final void paintLabel(Graphics g, int x, int y, int w, int h, int color1, int color2, int color3, int color4, int color5, int color6, int color7) {
		drawRect(g, x, y, w, h, color1, 0);
		drawRect(g, x, y, w, h, color2, 1);
		drawRect(g, x, y, w, h, color3, 2);

		int tempX = x + 3;
		int tempY = y + 3;
		int tempW = w - 6;// fill 小1
		int tempH = ((h - 7) >> 1);
		g.setColor(color4);
		g.drawLine(tempX, tempY, tempX + tempW, tempY);

		tempY += 1;
		g.setColor(color5);
		g.fillRect(tempX, tempY, tempW + 1, tempH);
		g.setColor(color6);
		tempY += tempH;
		tempH = h - 7 - tempH;
		g.fillRect(tempX, tempY, tempW + 1, tempH);
		g.setColor(color5);
		tempY = y + h - 3;
		g.drawLine(tempX, tempY, tempX + tempW, tempY);
	}

	/**
	 * 绘制一个带文字标签，文字居中显示
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 */
	public static final void paintLabelStr(Graphics g, int x, int y, int w, int h, String str, boolean isLight) {
		paintLabel(g, x, y, w, h, isLight);
		int color = isLight ? UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS) : UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS);
		int tempY = y + ((h - AbstractGameScreen.FONT_H) >> 1);
		if (str == null) {
			return;
		}
		g.setColor(color);
		g.drawString(str, x + (w >> 1), tempY, Tools.HCENTER_TOP);
	}

	/**
	 * 绘制一个带文字标签，文字居中显示
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isLight
	 * @param isSel
	 *            是否选中,绘制选中边框
	 */
	public static final void paintLabelStr(Graphics g, int x, int y, int w, int h, String str, boolean isLight, boolean isSel) {
		paintLabelStr(g, x, y, w, h, str, isLight);
		if (isSel) {
			UITools.paintFocusBox(g, x - 1, y - 2, w + 2, h + 4);
		}
	}

	/**
	 * 绘制一个带图片的标签，图片居中显示
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isLight
	 * @param isSel
	 *            是否选中,绘制选中边框
	 */
	public static final void paintLabelImage(Graphics g, int x, int y, int w, int h, Image image, boolean isLight, boolean isSel) {
		paintLabel(g, x, y, w, h, isLight);
		g.drawImage(image, x + (w >> 1), y + (h >> 1), Tools.HCENTER_VCENTER);
		if (isSel) {
			UITools.paintFocusBox(g, x - 1, y - 2, w + 2, h + 4);
		}
	}

	/**
	 * 绘制一个带图片的标签，图片居中显示
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param isLight
	 * @param isSel
	 *            是否选中,绘制选中边框
	 */
	public static final void paintLabelImage(Graphics g, int x, int y, int w, int h, Image image, boolean isLight) {
		paintLabelImage(g, x, y, w, h, image, isLight, false);
	}

	public static final void paintLabel(Graphics g, int x, int y, int w, int h, Image image, boolean isLight) {
		paintLabel(g, x, y, w, h, isLight);
	}

	public static final void paintScrollStr(Graphics g, int x, int y, int w, int h, String str) {
		paintScrollStr(g, x, y, w, h, str, 3, 1);
	}

	/**
	 * 绘制滚动文字 如果文字的宽度超出了W的范围，则滚动 2012-3-14 下午07:40:08 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param str
	 * @param speed
	 * @param direction
	 *            1 ,左移动 ；2 右移
	 */
	private static final void paintScrollStr(Graphics g, int x, int y, int w, int h, String str, int speed, int direction) {
		if (str == null) {
			return;
		}
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(x, y, w, h);
		int sw = AbstractGameScreen.s_font.stringWidth(str);
		if (sw > w) {
			sw += 5;// 间隔
			int iw = UIManager.TIME % sw;
			int tempX = x - iw;
			g.drawString(str, tempX, y, 0);
			g.drawString(str, tempX + sw, y, 0);
		} else {
			g.drawString(str, x, y, 0);
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 绘制道具或者技能的描述框 2012-2-16 上午09:58:55 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param temp
	 */
	public static final void paintItemDescribe(Graphics g, int x, int y, int w, int h, Object temp) {
		if (temp == null) {
			return;
		}
		int describeX = x;
		while (describeX + ITEM_DESCRIBEW > w) {
			describeX -= 5;
		}
		int describeY = y + UIManager.IMAGE_ITEM_OPEN.getHeight() + 2;
		if (temp instanceof ActorItem) {
			ActorItem item = (ActorItem) temp;
			paintActorItemDescribe(g, describeX, describeY, ITEM_DESCRIBEW, item);
		} else if (temp instanceof RoleCombatSkill) {
			RoleCombatSkill skill = (RoleCombatSkill) temp;
			paintSkillDescribe(g, describeX, describeY, ITEM_DESCRIBEW, skill);
		} else if (temp instanceof MenuFunction) {
			MenuFunction menu = (MenuFunction) temp;
			menu.drawDescribe(g, describeX, describeY);
		}
	}

	/**
	 * 绘制技能描述 2012-2-16 上午10:04:04 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param skill
	 */
	public static void paintSkillDescribe(Graphics g, int x, int y, int ITEM_DESCRIBEW, RoleCombatSkill skill) {
		if (skill == null) {
			return;
		}
		int IH_DESCRIBE = 3;// 框的间隙高度
		int RECTH_DESCRIBE = AbstractGameScreen.FONT_H + (IH_DESCRIBE << 1);
		UITools.drawRect(g, x, y, ITEM_DESCRIBEW, RECTH_DESCRIBE, 0x202221, 0);
		UITools.drawRect(g, x, y, ITEM_DESCRIBEW, RECTH_DESCRIBE, 0xefef8c, 1);
		UITools.drawRect(g, x, y, ITEM_DESCRIBEW, RECTH_DESCRIBE, 0x18424a, 2);
		UITools.fillRect(g, x, y, ITEM_DESCRIBEW, RECTH_DESCRIBE, 0x8c6b5a, 3);
		g.setColor(0xffef8b);
		int tempX = x + IH_DESCRIBE;
		int tempY = y + IH_DESCRIBE;
		String temp = skill.m_name;
		if (temp == null) {
			return;
		}
		g.drawString(temp, tempX, tempY, 0);
	}

	/**
	 * 绘制道具描述 2012-2-16 上午10:04:04 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param skill
	 */
	private static int x_name_equip = 0 ;
	public static void paintActorItemDescribe(Graphics g, int x, int y, int w, ActorItem item) {
		if (item == null) {
			return;
		}
		int IH_DESCRIBE = 3;// 框的间隙高度
		int H_JEWEL = UIManager.IMAGE_JEWEL_RECT.getHeight();// 宝石高度
		int H_STR = AbstractGameScreen.FONT_H + (IH_DESCRIBE << 1);
		int RECTH_DESCRIBE = 0;
		if (item instanceof ActorItemEquip) {
			ActorItemEquip equip = (ActorItemEquip) item;
			if (equip.m_color_jewels == null) {
				RECTH_DESCRIBE = H_STR;
			} else {
				RECTH_DESCRIBE = H_STR + H_JEWEL;
			}
		} else {
			RECTH_DESCRIBE = H_STR;
		}
		UITools.drawRect(g, x, y, w, RECTH_DESCRIBE, 0x202221, 0);
		UITools.drawRect(g, x, y, w, RECTH_DESCRIBE, 0xefef8c, 1);
		UITools.drawRect(g, x, y, w, RECTH_DESCRIBE, 0x18424a, 2);
		UITools.fillRect(g, x, y, w, RECTH_DESCRIBE, 0x8c6b5a, 3);
		int tempX = x + IH_DESCRIBE;
		int tempY = y + IH_DESCRIBE;
		//
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		int nw = w - (IH_DESCRIBE<<1);
		g.setClip(tempX, tempY, nw, AbstractGameScreen.FONT_H);
		int endX = item.drawName(g, tempX - x_name_equip, tempY);
		int sw = endX - tempX ;
		if (sw > nw) {
//			item.drawName(g, tempX - x_name_equip + sw, tempY) ;
			x_name_equip++ ;
			if (x_name_equip >= sw ) {
				x_name_equip = 0 ;
			}
		}else{
			x_name_equip = 0 ;
		}
		g.setClip(clipX, clipY, clipW, clipH);
		if (item instanceof ActorItemEquip) {
			ActorItemEquip equip = (ActorItemEquip) item;
			// 绘制宝石
			if (equip.m_color_jewels == null) {
				return;
			}
			tempX = x + IH_DESCRIBE;
			tempY += AbstractGameScreen.FONT_H;
			ActorItemEquip.drawJewel(g, tempX, tempY, equip);
		}
	}

	/**
	 * 绘制标签箭头，带*#的那种 2012-2-20 下午03:15:36 venizeng
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param isLeft
	 *            是否是左箭头
	 * @param boolean isLight 当前街头是否高亮
	 */
	public static final void paintLabelArr(Graphics g, int x, int y, boolean isLeft, boolean isLight) {
		int num = UIManager.TIME % 7;
		if (num >= 3) {
			num = 7 - num;
		}
		if (isLeft) {
			x -= num;
		} else {
			x += num;
		}
		//
		int tempW = (UIManager.IMAGE_LABEL_ARR.getWidth());
		int tempH = UIManager.IMAGE_LABEL_ARR.getHeight();
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(x, y, tempW, tempH);
		//
		if (isLeft) {
			g.drawRegion(UIManager.IMAGE_LABEL_ARR, 0, 0, tempW, tempH, 0, x, y, 0);
			g.drawRegion(UIManager.IMAGE_XINGJING, 0, 0, 7, 8, 0, x + 10, y + 6, 0);
		} else {
			g.drawRegion(UIManager.IMAGE_LABEL_ARR, 0, 0, tempW, tempH, Sprite.TRANS_MIRROR, x, y, 0);
			g.drawRegion(UIManager.IMAGE_XINGJING, 7, 0, 7, 8, 0, x + 4, y + 6, 0);
		}
		g.setClip(clipX, clipY, clipW, clipH);
	}

	// ///////////////////////////////////////////////////////////////d
	public static final String SIGN_ARE_SLASH = "/";
	//#if screen == "320240"
	//# public static final int GAP_WINDOW_SCREEN_UP = 0;// 屏幕与UI窗体之间空隙 上
	//# public static final int GAP_WINDOW_SCREEN_LEFT = 52;// 左
	//# public static final int GAP_WINDOW_SCREEN_RIGHT = 52;// 右
	//# public static final int GAP_WINDOW_SCREEN_DOWN = 0;// 下
	//#else
	public static final int GAP_WINDOW_SCREEN_UP = 12;// 屏幕与UI窗体之间空隙 上
	public static final int GAP_WINDOW_SCREEN_LEFT = 12;// 左
	public static final int GAP_WINDOW_SCREEN_RIGHT = 12;// 右
	public static final int GAP_WINDOW_SCREEN_DOWN = 23;// 下
	//#endif

	public static final int GAP_WINDOW_SUBCOAT_UP = 2;// UI窗体与内层框的空隙 上需要加上标题高度
	public static final int GAP_WINDOW_SUBCOAT_LEFT = 9;// 左右空隙不需要处理
	public static final int GAP_WINDOW_SUBCOAT_RIGHT = 16;
	public static final int GAP_WINDOW_SUBCOAT_DOWN = 0;// 下需要加上左右按钮高度
	// 内容框每一栏的高度
	public static final int GAP_EACH_LINE = 2;// 字与字之间每行的间距
	public static final int H_SINGLE_BAR = AbstractGameScreen.s_font.getHeight() + GAP_EACH_LINE;// 内容显示单栏高度
	public static final int H_SUBCOAT_SIDE = 6;// 内层窗体边宽
	public static final int H_WIN_SIDE = 8;// 外层窗体边宽

	// 文字显示
	public static final int GAP_LEFT = (H_SUBCOAT_SIDE >> 1) + 2;
	public static final int GAP_UP = (H_SUBCOAT_SIDE >> 1) + 1;

	// 左软键
	//#if screen == "320240"
	//# public static final int W_SOFTKEY = 0;
	//# public static final int H_SOFTKEY = 0;
	//#else
	public static final int W_SOFTKEY = 53;
	public static final int H_SOFTKEY = H_LABEL;
	//#endif

	// 标题按钮 - 超大
	public static final int W_BUTTON_HUGE = 72;
	// 标题按钮 - 大
	public static final int W_BUTTON_BIG = 50;
	// 标题按钮 - 中
	public static final int W_BUTTON_MIDDLE = 34;
	// 标题按钮 - 小
	public static final int W_BUTTON_SMALL = 26;
	// 标题按钮
	public static final int H_BUTTON = 22;
	
	public static final byte BUTTON_INDEX_QUEDING = 1;
	public static final byte BUTTON_INDEX_FANHUI = 2;
	public static final byte BUTTON_INDEX_CAOZUO = 3;
	public static final byte BUTTON_INDEX_JIESHOU = 4;
	public static final byte BUTTON_INDEX_WANCHENG = 5;
	public static final byte BUTTON_INDEX_XUNLU = 6;
	public static final byte BUTTON_INDEX_AN5JIAN = 7;
	public static final byte BUTTON_INDEX_KAISHI = 8;

	// 背景
	public static final int X_BG = GAP_WINDOW_SCREEN_LEFT;
	public static final int Y_BG = GAP_WINDOW_SCREEN_UP;
	public static final int W_BG = AbstractGameScreen.SCREEN_WIDTH - GAP_WINDOW_SCREEN_LEFT - GAP_WINDOW_SCREEN_RIGHT;
	public static final int H_BG = AbstractGameScreen.SCREEN_HEIGHT - GAP_WINDOW_SCREEN_UP - GAP_WINDOW_SCREEN_DOWN;
	// 标题栏
	public static final int X_TITLE = X_BG;
	public static final int Y_TITLE = Y_BG;
	public static final int W_TITLE = W_BG;
	//#if screen == "320240"
	//# public static final int H_TITLE = 0;
	//#else
	public static final int H_TITLE = 23;
	//#endif

	// 小背景
	public static final int X_BG_SMALL = GAP_WINDOW_SCREEN_LEFT;
	public static final int Y_BG_SMALL = AbstractGameScreen.SCREEN_HEIGHT >> 2;
	public static final int W_BG_SMALL = AbstractGameScreen.SCREEN_WIDTH - GAP_WINDOW_SCREEN_LEFT - GAP_WINDOW_SCREEN_RIGHT;
	public static final int H_BG_SMALL = AbstractGameScreen.SCREEN_HEIGHT >> 1;
	public static final int AMOUNT_SMALL_CONTENT = (H_BG_SMALL - 23 - H_SOFTKEY) / H_SINGLE_BAR;

	// 内层窗体 - 有标题按钮
	public static final int H_SUBCOAT_HT_TRUE = H_BG - H_TITLE - H_BUTTON - H_SOFTKEY - (GAP_WINDOW_SUBCOAT_UP << 1) - H_SUBCOAT_SIDE;// 内层有标题窗体实际显示高度
	public static final int AMOUNT_SUBCOAT_HT_CONTENT = H_SUBCOAT_HT_TRUE / H_SINGLE_BAR;// 内容显示数量

	public static final int X_SUBCOAT_HT = X_BG + GAP_WINDOW_SUBCOAT_LEFT + (H_WIN_SIDE >> 1);
	public static final int Y_SUBCOAT_HT = Y_BG + H_TITLE + GAP_WINDOW_SUBCOAT_UP + H_BUTTON;
	public static final int W_SUBCOAT_HT = W_BG - GAP_WINDOW_SUBCOAT_LEFT - GAP_WINDOW_SUBCOAT_RIGHT - H_WIN_SIDE;
	public static final int H_SUBCOAT_HT = H_SINGLE_BAR * AMOUNT_SUBCOAT_HT_CONTENT + H_SUBCOAT_SIDE;

	// 内层窗体 - 无标题按钮
	public static final int H_SUBCOAT_NT_TRUE = H_BG - H_TITLE - H_SOFTKEY - H_SUBCOAT_SIDE - (GAP_WINDOW_SUBCOAT_UP << 1);// 内层无标题窗体实际显示高度
	public static final int AMOUNT_SUBCOAT_NT_CONTENT = H_SUBCOAT_NT_TRUE / H_SINGLE_BAR;// 内容显示数量
	public static final int X_SUBCOAT_NT = X_BG + GAP_WINDOW_SUBCOAT_LEFT + (H_WIN_SIDE >> 1);
	public static final int Y_SUBCOAT_NT = Y_BG + H_TITLE + GAP_WINDOW_SUBCOAT_UP;
	public static final int W_SUBCOAT_NT = W_BG - GAP_WINDOW_SUBCOAT_LEFT - GAP_WINDOW_SUBCOAT_LEFT - H_WIN_SIDE;
	public static final int H_SUBCOAT_NT = H_SINGLE_BAR * AMOUNT_SUBCOAT_NT_CONTENT + H_SUBCOAT_SIDE;

	// 滚动条
	public static final int X_SCROLL_BAR = X_SUBCOAT_HT + W_SUBCOAT_HT + 3;
	public static final int Y_SCROLL_BAR = Y_SUBCOAT_HT;
	public static final int W_SCROLL_BAR = 12;
	public static final int H_SCROLL_BAR = H_SUBCOAT_HT;

	// 标题按钮
	public static final int X_BUTTON_3BIG = X_BG + (W_BG >> 1) - W_BUTTON_BIG - (W_BUTTON_BIG >> 1);
	public static final int X_BUTTON_4MID = X_SUBCOAT_HT + (W_SUBCOAT_HT >> 1) - (W_BUTTON_MIDDLE << 1);
	public static final int Y_BUTTON = Y_TITLE + H_TITLE + GAP_WINDOW_SUBCOAT_UP;

	// 上半部内层无标题窗体
	public static final int X_COVER_SUBCOAT = X_SUBCOAT_HT;
	public static final int Y_COVER_SUBCOAT = Y_BG + H_TITLE + GAP_WINDOW_SUBCOAT_UP;
	public static final int W_COVER_SUBCOAT = W_BG - GAP_WINDOW_SUBCOAT_LEFT - GAP_WINDOW_SUBCOAT_LEFT - H_WIN_SIDE;
	public static final int H_COVER_SUBCOAT = H_SUBCOAT_NT >> 1;
	// 下半部内层无标题窗体
	public static final int X_BASE_SUBCOAT = X_SUBCOAT_HT;
	public static final int Y_BASE_SUBCOAT = Y_COVER_SUBCOAT + H_COVER_SUBCOAT + GAP_EACH_LINE;
	public static final int W_BASE_SUBCOAT = W_COVER_SUBCOAT;
	public static final int H_BASE_SUBCOAT = H_SUBCOAT_NT >> 1;

	// 2/3的上半部内层无标题窗体
	public static final int X_32_SUBCOAT = X_SUBCOAT_HT;
	public static final int Y_32_SUBCOAT = Y_COVER_SUBCOAT;
	public static final int W_32_SUBCOAT = W_COVER_SUBCOAT - GAP_LEFT + 2;
	public static final int H_32_SUBCOAT = (H_SUBCOAT_NT_TRUE - GAP_EACH_LINE) / 3 * 2;
	public static final int AMOUNT_SUBCOAT_32_CONTENT = H_32_SUBCOAT / H_SINGLE_BAR;

	// 1/3的下半部内层无标题窗体
	public static final int X_31_SUBCOAT = X_SUBCOAT_HT;
	public static final int Y_31_SUBCOAT = Y_32_SUBCOAT + H_32_SUBCOAT + GAP_EACH_LINE;
	public static final int W_31_SUBCOAT = W_32_SUBCOAT;
	public static final int H_31_SUBCOAT = H_SUBCOAT_NT_TRUE / 3;
	public static final int AMOUNT_SUBCOAT_31_CONTENT = H_31_SUBCOAT / H_SINGLE_BAR;

	// 小的居中内层窗体
	public static final int X_SMALL_SUBCOAT = X_BG_SMALL + GAP_WINDOW_SUBCOAT_LEFT + (H_WIN_SIDE >> 1);
	public static final int Y_SMALL_SUBCOAT = Y_BG_SMALL + 23 + GAP_WINDOW_SUBCOAT_UP;
	public static final int W_SMALL_SUBCOAT = W_COVER_SUBCOAT;
	public static final int H_SMALL_SUBCOAT = H_BG_SMALL - 23 - H_SINGLE_BAR - GAP_WINDOW_SUBCOAT_UP - 23;

	public static final void drawListContent(Graphics g, int x, int y, String[] list) {

	}

	/**
	 * 绘制标签箭头
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 *            中间宽度
	 * @param isLeft
	 *            是否绘制左侧
	 * @param isRight
	 *            是否绘制右侧
	 */
	public static final void drawLabelArrows(Graphics g, int x, int y, int w, boolean isLeft, boolean isRight) {
		int hw = UIManager.IMAGE_LABEL_ARR.getWidth();
		int hh = UIManager.IMAGE_LABEL_ARR.getHeight();

		int num = UIManager.TIME % 7;
		if (num >= 3) {
			num = 7 - num;
		}
		if (isLeft) {
			g.setClip(x - hw - 5 - num, y, hw, hh);
			g.drawImage(UIManager.IMAGE_LABEL_ARR, x - hw - 5 - num, y, Tools.LEFT_TOP);
			g.drawRegion(UIManager.IMAGE_XINGJING, 0, 0, 7, 8, 0, x - 15 - num, y + 6, 0);
			// drawColorString(g, "*", x - 9, y + 3, Tools.WHITE,
			// Tools.RIGHT_TOP);
		}
		if (isRight) {
			g.setClip(x + w + 5 + num, y, hw, hh);
			Tools.drawRegion(g, UIManager.IMAGE_LABEL_ARR, x + w + 5 + num, y, Tools.TRANS_H, Tools.LEFT_TOP);
			g.drawRegion(UIManager.IMAGE_XINGJING, 7, 0, 7, 8, 0, x + w + 9 + num, y + 6, 0);
			// drawColorString(g, "#", x + w + 9, y, Tools.WHITE,
			// Tools.LEFT_TOP);
		}
	}

	/**
	 * 通过秒数求小时
	 * 
	 * @param second
	 * @return
	 */
	public static final int getHourBySecond(long second) {
		return (int) (second / 3600);
	}

	/**
	 * 通过秒数求分钟
	 * 
	 * @param second
	 * @return
	 */
	public static final int getMinuteBySecond(long second) {
		return (int) (second / 60 % 60);
	}

	/**
	 * 通过秒数求剩余秒数
	 * 
	 * @param second
	 * @return
	 */
	public static final int getSecondBySecond(long second) {
		return (int) (second % 60);
	}

	/**
	 * d 根据宽度拆分字符
	 * 
	 * @param text
	 * @param w
	 * @return
	 */
	public static final String[] splitString(String text, int w) {
		ArrayList texts = new ArrayList();
		String temp = "";
		int amountW = 0, curW = 0;
		for (int i = 0; i < text.length(); i++) {
			if (i == text.length() - 1) {
				texts.addElement(temp + text.substring(i, text.length()));
				break;
			} else {
				amountW = AbstractGameScreen.s_font.stringWidth(temp);
				curW = AbstractGameScreen.s_font.stringWidth(text.substring(i, i + 1));
				if (amountW + curW > w) {
					texts.addElement(temp);
					temp = text.substring(i, i + 1);
				} else {
					temp += text.substring(i, i + 1);
				}
			}
		}
		String[] list = new String[texts.size()];
		for (int i = 0; i < list.length; i++) {
			list[i] = texts.elementAt(i).toString();
		}
		return list;
	}

	/**
	 * d绘制计时条,以分钟为单位
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param time
	 */
	public static final void drawTimeBar(Graphics g, int x, int y, int w, long curTime, long amoTime) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		int[] colors = UIManager.getTimeBarColor();
		for (int i = 0; i < colors.length; i++) {
			g.setColor(colors[i]);
			g.drawLine(x, y + i + 1, x + w, y + i + 1);
		}
		int temp = (int) ((curTime * 100 / amoTime) * w / 100);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_TIME_BAR_UP));
		g.drawLine(x, y + (colors.length >> 1), x + temp, y + (colors.length >> 1));
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_TIME_BAR_DOWN));
		g.drawLine(x, y + (colors.length >> 1) + 1, x + temp, y + (colors.length >> 1) + 1);

		g.drawImage(GameManager.getInstance().img_time_bar_left, x, y + 1, Tools.RIGHT_TOP);
		g.drawImage(GameManager.getInstance().img_time_bar_right, x + w - 2, y, Tools.LEFT_TOP);

		drawColorString(g, WORD_SURPLUS + WORD_COLON + getTimeBySecond(curTime), x + (w >> 1), y, UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS), Tools.HCENTER_BOTTOM);
	}

	public static final String WORD_COLON = " : ";
	public static final String WORD_SURPLUS = "剩余时间 : ";
	public static final String WORD_HOUR = "小时";
	public static final String WORD_MINUTE = "分";
	public static final String WORD_SECOND = "秒";

	/**
	 * 通过秒数得到剩余时间的字符串
	 * 
	 * @param second
	 * @return
	 */
	public static final String getTimeBySecond(long second) {
		return getHourBySecond(second) + WORD_HOUR + getMinuteBySecond(second) + WORD_MINUTE + getSecondBySecond(second) + WORD_SECOND;
	}

	/**
	 * d绘制页码
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param page
	 *            当前页 0 开始
	 * @param amount
	 *            总页数
	 */
	public static final void drawPageNumber(Graphics g, int x, int y, int page, int amount) {
		if (amount <= 0) {
			drawColorString(g, page + SIGN_ARE_SLASH + amount, x, y, UIManager.getPaletteColor(UIPalette.COLOR_WORD_NOS), Tools.HCENTER_BOTTOM);
		} else {
			drawColorString(g, (page + 1) + SIGN_ARE_SLASH + amount, x, y, UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS), Tools.HCENTER_BOTTOM);
		}
		int len = (AbstractGameScreen.s_font.stringWidth((page + 1) + SIGN_ARE_SLASH + amount) >> 1) + 5;
		Tools.drawRegion(g, GameManager.getInstance().img_page_corner, x - len, y, Tools.TRANS_90, Tools.RIGHT_BOTTOM);
		Tools.drawRegion(g, GameManager.getInstance().img_page_corner, x + len, y, Tools.TRANS_270, Tools.LEFT_BOTTOM);
	}

	/**
	 * d 绘制滚动条
	 * 
	 * @param g
	 * @param arrows
	 * @param ruling
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param plan
	 *            进度
	 */
	public static final void drawScrollBar(Graphics g, int x, int y, int h, int plan) {
		g.setClip(x, y, W_SCROLL_BAR, h);
		int rulingx = x + ((W_SCROLL_BAR - UIManager.getColorsScrollBar().length) >> 1);
		int rulingy = y + UIManager.IMAGE_SCROLL_ARR.getHeight();
		int rulingh = h - (UIManager.IMAGE_SCROLL_ARR.getHeight() << 1);
		for (int i = 0; i < UIManager.getColorsScrollBar().length; i++) {
			g.setColor(UIManager.getColorsScrollBar()[i]);
			g.drawLine(rulingx + i, rulingy, rulingx + i, rulingy + rulingh);
		}
		g.drawImage(UIManager.IMAGE_SCROLL_ARR, x, y + h, Tools.LEFT_BOTTOM);
		Tools.drawRegion(g, UIManager.IMAGE_SCROLL_ARR, x, y, Tools.TRANS_V, Tools.LEFT_TOP);
		if (plan != -1) {
			g.drawImage(UIManager.IMAGE_SCROLL_RULING, rulingx + 2,
					rulingy + (UIManager.IMAGE_SCROLL_RULING.getHeight() >> 1) + plan * (rulingh - UIManager.IMAGE_SCROLL_RULING.getHeight()) / 100, Tools.HCENTER_VCENTER);
		}
	}

	/**
	 * d 获得滚动列表下标和页数
	 * 
	 * @param index
	 *            当前下标(不包含页数)
	 * @param page
	 *            当前页数
	 * @param len
	 *            总长度
	 * @param amount
	 *            每页显示长度
	 * @param operation
	 *            加减
	 * @return
	 */
	public static byte[] keyPressedIndexPage(byte index, byte page, int len, int amount, boolean operation) {
		byte[] result = new byte[2];
		if (len <= 0) {
			return result;
		} else if (len <= amount) {
			if (operation) {// -
				index = (byte) (--index < 0 ? (len - 1) : index);
			} else {// +
				index = ++index >= len ? 0 : index;
			}
			page = 0;
		} else {
			if (operation) {// -
				if (index == 0) {
					if (page == 0) {
						page = (byte) (len - amount);
						index = (byte) (amount - 1);
					} else {
						page--;
					}
				} else {
					index--;
				}
			} else {// +
				if (index == amount - 1) {
					if (page == len - amount) {
						page = 0;
						index = 0;
					} else {
						page++;
					}
				} else {
					index++;
				}
			}
		}
		result[KPIP_INDEX] = index;
		result[KPIP_PAGE] = page;
		return result;
	}

	/** 索引 */
	public static final int KPIP_INDEX = 0;
	/** 页数 */
	public static final int KPIP_PAGE = 1;
	/** 减 */
	public static final boolean OPERATION_MINUS = true;
	/** 加 */
	public static final boolean OPERATION_ADD = false;

	/**
	 * d 绘制选择框
	 * 
	 * @param g
	 * @param img
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawImageSelectBox(Graphics g, int x, int y, int w, int h) {
		int cx = g.getClipX();
		int cy = g.getClipY();
		int cw = g.getClipWidth();
		int ch = g.getClipHeight();
		g.setClip(x, y, w, h);
		g.drawImage(UIManager.IMAGE_SEL, x, y, Tools.LEFT_TOP);// 左上
		Tools.drawRegion(g, UIManager.IMAGE_SEL, x + w, y, Tools.TRANS_H, Tools.RIGHT_TOP);// 右上
		Tools.drawRegion(g, UIManager.IMAGE_SEL, x, y + h, Tools.TRANS_V, Tools.LEFT_BOTTOM);// 左下
		Tools.drawRegion(g, UIManager.IMAGE_SEL, x + w, y + h, Tools.TRANS_HV, Tools.RIGHT_BOTTOM);// 右下
		g.setClip(cx, cy, cw, ch);
	}

	/**
	 * d 绘制窗体背景
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawWindowBackgroud(Graphics g) {
		g.setClip(X_BG, Y_BG, W_BG + 1, H_BG + 1);
		drawFillRectAlpha(g, X_BG, Y_BG, W_BG, H_BG, UIManager.getPaletteColor(UIManager.COLOR_BACKGROUND));
		int[] colors = UIManager.getColorsWinBorder();
		for (int i = 0; i < colors.length; i++) {
			// drawColorRect(g, X_BG + i, Y_BG + i, W_BG - (i << 1) - 1, H_BG -
			// (i << 1) - 1,
			// UIManager.getColorsWinBorder()[i]);
			drawRect(g, X_BG, Y_BG, W_BG - 1, H_BG - 1, colors[i], i);
		}
	}

	/**
	 * d 绘制小的窗体背景
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawWindowSmallBackgroud(Graphics g) {
		g.setClip(X_BG_SMALL, Y_BG_SMALL, W_BG_SMALL, H_BG_SMALL);
		drawFillRectAlpha(g, X_BG_SMALL, Y_BG_SMALL, W_BG_SMALL, H_BG_SMALL, UIManager.getPaletteColor(UIManager.COLOR_BACKGROUND));
		for (int i = 0; i < UIManager.getColorsWinBorder().length; i++) {
			drawColorRect(g, X_BG_SMALL + i, Y_BG_SMALL + i, W_BG_SMALL - (i << 1) - 1, H_BG_SMALL - (i << 1) - 1, UIManager.getColorsWinBorder()[i]);
		}
	}

	/**
	 * d 绘制窗体带标题
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawWindowBackgroud(Graphics g, int x, int y, int w, int h) {
		g.setClip(x, y, w, h);
		drawFillRectAlpha(g, x, y, w, h, UIManager.getPaletteColor(UIManager.COLOR_BACKGROUND));
		int[] colors = UIManager.getColorsWinBorder();
		for (int i = 0, length = colors.length; i < length; i++) {
			drawColorRect(g, x + i, y + i, w - (i << 1) - 1, h - (i << 1) - 1, colors[i]);
		}
	}

	/**
	 * d 绘制内层窗体, 不带背景
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawWindowSubcoat(Graphics g, int x, int y, int w, int h) {
		g.setClip(x, y, w, h);
		for (int i = 0; i < UIManager.getColorsSubcoatBorder().length; i++) {
			drawColorRect(g, x + i, y + i, w - (i << 1) - 1, h - (i << 1) - 1, UIManager.getColorsSubcoatBorder()[i]);
		}
	}

	/**
	 * d 绘制内层窗体, 带背景
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawWindowSubcoat(Graphics g, int x, int y, int w, int h, int color) {
		g.setColor(color);
		g.setClip(x, y, w, h);
		g.fillRect(x, y, w, h);
		for (int i = 0; i < UIManager.getColorsSubcoatBorder().length; i++) {
			drawColorRect(g, x + i, y + i, w - (i << 1) - 1, h - (i << 1) - 1, UIManager.getColorsSubcoatBorder()[i]);
		}
	}

	// /**
	// * d 绘制上半部内层窗体, 带背景
	// * @param g
	// * @param x
	// * @param y
	// * @param w
	// * @param h
	// */
	// public static final void drawWindowCoverSubcoat(Graphics g, int color)
	// {
	// g.setColor(color);
	// g.setClip(COORD_X_COVER_SUBCOAT, COORD_Y_COVER_SUBCOAT,
	// WIDTH_COVER_SUBCOAT, HEIGHT_COVER_SUBCOAT);
	// g.fillRect(COORD_X_COVER_SUBCOAT, COORD_Y_COVER_SUBCOAT,
	// WIDTH_COVER_SUBCOAT, HEIGHT_COVER_SUBCOAT);
	// for (int i = 0; i < UIManager.getColorsSubcoatBorder().length; i++) {
	// drawColorRect(g, COORD_X_COVER_SUBCOAT + i, COORD_Y_COVER_SUBCOAT + i,
	// WIDTH_COVER_SUBCOAT - (i << 1) - 1, HEIGHT_COVER_SUBCOAT - (i << 1) - 1,
	// UIManager.getColorsSubcoatBorder()[i]);
	// }
	// }
	// /**
	// * d 绘制下半部内层窗体, 带背景
	// * @param g
	// * @param x
	// * @param y
	// * @param w
	// * @param h
	// */
	// public static final void drawWindowBaseSubcoat(Graphics g, int color)
	// {
	// g.setColor(color);
	// g.setClip(COORD_X_BASE_SUBCOAT, COORD_Y_BASE_SUBCOAT, WIDTH_BASE_SUBCOAT,
	// HEIGHT_BASE_SUBCOAT);
	// g.fillRect(COORD_X_BASE_SUBCOAT, COORD_Y_BASE_SUBCOAT,
	// WIDTH_BASE_SUBCOAT, HEIGHT_BASE_SUBCOAT);
	// for (int i = 0; i < UIManager.getColorsSubcoatBorder().length; i++) {
	// drawColorRect(g, COORD_X_BASE_SUBCOAT + i, COORD_Y_BASE_SUBCOAT + i,
	// WIDTH_BASE_SUBCOAT - (i << 1) - 1, HEIGHT_BASE_SUBCOAT - (i << 1) - 1,
	// UIManager.getColorsSubcoatBorder()[i]);
	// }
	// }

	/**
	 * d 绘制标题栏
	 * 
	 * @param g
	 * @param side
	 *            左边图片
	 * @param middle
	 *            中间图片
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawTitle(Graphics g, String text) {
		//#if screen == "320240"
		//# paintBackgroundTitleOn320240(g, X_TITLE -
		//# UIManager.IMAGE_TITlE_SMALL.getHeight(), Y_TITLE,
		//# UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, text);
		//# paintBackgroundTitleOn320240(g, X_TITLE + W_TITLE, Y_TITLE,
		//# UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, null);
		//#else
		paintBackgroundTitleOn240320(g, X_TITLE, Y_TITLE, W_TITLE, H_TITLE, text);
		//#endif
	}

	/**
	 * d 根据x,y,w,h绘制标题栏
	 * 
	 * @param g
	 * @param side
	 *            左边图片
	 * @param middle
	 *            中间图片
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawTitle(Graphics g, String text, int x, int y, int w, int h) {
		//#if screen == "320240"
		//# paintBackgroundTitleOn320240(g, x - UIManager.IMAGE_TITlE_SMALL.getHeight(), y, UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, text);
		//# paintBackgroundTitleOn320240(g, x + w, y, UIManager.IMAGE_TITlE_SMALL.getWidth() << 1, null);
		//#else
		paintBackgroundTitleOn240320(g, x, y, w, h, text);
		//#endif
	}

	/**
	 * d 绘制字符串列表
	 * 
	 * @param g
	 * @param list
	 * @param x
	 * @param y
	 * @param cur
	 *            当前索引
	 * @param amount
	 *            每页的显示数
	 * @param color
	 */
	public static final void drawStringList(Graphics g, String[] list, int x, int y, int cur, int amount, int color) {
		if (list != null) {
			for (int i = cur; i < list.length; i++) {
				if (i - cur < amount) {
					drawColorString(g, list[i], x, y + (i - cur) * H_SINGLE_BAR, color, Tools.LEFT_TOP);
				}
			}
		}
	}

	/**
	 * d 绘制一个带颜色的框
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color
	 */
	public static final void drawColorRect(Graphics g, int x, int y, int w, int h, int color) {
		g.setColor(color);
		g.drawRect(x, y, w, h);
	}

	/**
	 * d 绘制一个带颜色的实心框
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color
	 */
	public static final void drawColorFillRect(Graphics g, int x, int y, int w, int h, int color) {
		g.setColor(color);
		g.fillRect(x, y, w, h);
	}

	/**
	 * d 绘制一个带颜色的字
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param color
	 * @param anchor
	 */
	public static final void drawColorString(Graphics g, String text, int x, int y, int color, int anchor) {
		if (text != null) {
			g.setColor(color);
			g.drawString(text, x, y, anchor);
		}
	}

	/**
	 * d 清屏
	 * 
	 * @param g
	 */
	public static final void clearScreen(Graphics g) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
	}

	/**
	 * d 绘制透明框
	 */
	public static final void drawFillRectAlpha(Graphics g, int x, int y, int w, int h, int color) {
		//#if lucency == "YES"
//		DirectUtils.getDirectGraphics(g).fillPolygon(new int[] { x, x, x + w - 1, x + w - 1 }, 0, new int[] { y, y + h - 1, y + h - 1, y }, 0, 4, color);
		//#else
		//# g.setColor(color);
		//# g.fillRect(x, y, w, h);
		//#endif
	}

	/**
	 * d 绘制左右软键,不带角
	 * 
	 * @param g
	 * @param softkey
	 * @param left
	 * @param right
	 */
	public static final void drawWindowSoftkeyNone(Graphics g, String left, String right) {
		if (left != null) {
			g.setClip(X_BG, Y_BG + H_BG - H_BUTTON, W_SOFTKEY, H_SOFTKEY);
			g.drawImage(GameManager.getInstance().img_softkey, X_BG + 1, Y_BG + H_BG, Tools.LEFT_BOTTOM);
			drawColorString(g, left, X_BG + 8, Y_BG + H_BG, 0xF3F389, Tools.LEFT_BOTTOM);
		}
		if (right != null) {
			g.setClip(X_BG + W_BG - W_SOFTKEY, Y_BG + H_BG - H_BUTTON, W_SOFTKEY, H_SOFTKEY);
			Tools.drawRegion(g, GameManager.getInstance().img_softkey, X_BG + W_BG - 1, Y_BG + H_BG, Tools.TRANS_H, Tools.RIGHT_BOTTOM);
			drawColorString(g, right, X_BG + W_BG - 8, Y_BG + H_BG, 0xF3F389, Tools.RIGHT_BOTTOM);
		}
	}

	/**
	 * d 绘制左右软键,带角
	 * 
	 * @param g
	 * @param softkey
	 * @param corner
	 * @param left
	 * @param right
	 */
	public static final void drawWindowSoftkey(Graphics g, String left, String right) {
		//#if screen == "320240"
		//# paintBackgroundButtonOn320240(g, X_BG, Y_BG + H_BG - H_LABEL, W_BG, H_LABEL);
		//#else
		if (left != null) {
			g.setClip(X_BG + 3, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, X_BG + 3, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG, H_LABEL, left, true);
		}
		if (right != null) {
			g.setClip(X_BG + W_BG - W_LABEL_BIG - 4, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, X_BG + W_BG - W_LABEL_BIG - 4, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG, H_LABEL, right, true);
		}
		//#endif
	}
	
	/**
	 * d 绘制左右软键,带角
	 * 
	 * @param g
	 * @param softkey
	 * @param corner
	 * @param left
	 * @param right
	 */
	public static final void drawWindowSoftkey(Graphics g, byte left, byte right) {
		//#if screen == "320240"
		//# paintBackgroundButtonOn320240(g, X_BG, Y_BG + H_BG - H_LABEL, W_BG, H_LABEL);
		//#else
		paintBackgroundButton(g, 0, 0, 0, 0, left>0, right>0);// 绘制按钮
//		if (left > 0) {
//			g.setClip(X_BG + 3, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
//			paintLabelImage(g, X_BG + 3, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG, H_LABEL, getButtonImage(left), true);
//		}
//		if (right > 0) {
//			g.setClip(X_BG + W_BG - W_LABEL_BIG - 4, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
//			paintLabelImage(g, X_BG + W_BG - W_LABEL_BIG - 4, Y_BG + H_BG - H_LABEL - 3, W_LABEL_BIG, H_LABEL, getButtonImage(right), true);
//		}
		//#endif
	}
	/**
	 * 绘制中间的按5键寻路
	 * @param g
	 * @param x
	 * @param y
	 * @param anchor
	 */
	public static final void drawMiddleKey(Graphics g, int x, int y, int anchor) {
		g.drawImage(UIManager.IMAGE_BUTTON_AN5JIAN, x, y, anchor);
	}
	
	private static Image getButtonImage(byte index) {
		switch (index) {
			case BUTTON_INDEX_QUEDING:
				return UIManager.IMAGE_BUTTON_QUEDING;
			case BUTTON_INDEX_FANHUI:
				return UIManager.IMAGE_BUTTON_FANHUI;
			case BUTTON_INDEX_WANCHENG:
				return UIManager.IMAGE_BUTTON_WANCHENG;
			case BUTTON_INDEX_JIESHOU:
				return UIManager.IMAGE_BUTTON_JIESHOU;
			case BUTTON_INDEX_CAOZUO:
				return UIManager.IMAGE_BUTTON_CAOZUO;
			case BUTTON_INDEX_XUNLU:
				return UIManager.IMAGE_BUTTON_XUNLU;
			case BUTTON_INDEX_AN5JIAN:
				return UIManager.IMAGE_BUTTON_AN5JIAN;
			case BUTTON_INDEX_KAISHI:
				return UIManager.IMAGE_BUTTON_KAISHI;
		}
		Tools.debugPrintln("绘制左右软键下标错误!" + index);
		return null;
	}

	/**
	 * d 绘制左右软键,带角
	 * 
	 * @param g
	 * @param softkey
	 * @param corner
	 * @param left
	 * @param right
	 */
	public static final void drawWindowSoftkey(Graphics g, String left, String right, int x, int y, int w, int h) {
		//#if screen == "320240"
		//# paintBackgroundButtonOn320240(g, x + 3, y + h - H_LABEL - 3, W_BG, H_LABEL);
		//#else
		if (left != null) {
			g.setClip(x + 3, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, x + 3, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, left, true);
		}
		if (right != null) {
			g.setClip(x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, right, true);
		}
		//#endif
	}

	public static final void drawSoftkey(Graphics g, String left, String right, int x, int y, int w, int h) {
		if (left != null) {
			g.setClip(x + 3, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, x + 3, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, left, true);
		}
		if (right != null) {
			g.setClip(x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			UITools.paintLabelStr(g, x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, right, true);
		}
	}

	public static final void drawSoftkey(Graphics g, byte left, byte right, int x, int y, int w, int h) {
		if (left > 0) {
			g.setClip(x + 3, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			paintLabelImage(g, x + 3, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, getButtonImage(left), true);
		}
		if (right > 0) {
			g.setClip(x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG + 1, H_LABEL + 1);
			paintLabelImage(g, x + w - W_LABEL_BIG - 4, y + h - H_LABEL - 3, W_LABEL_BIG, H_LABEL, getButtonImage(right), true);
		}
	}
	
	/**
	 * 绘制选择框
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static final void drawSelectBox(Graphics g, int x, int y, int w, int h) {
		int cx = g.getClipX();
		int cy = g.getClipY();
		int cw = g.getClipWidth();
		int ch = g.getClipHeight();
		int color = g.getColor();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_SELECT_BOX_OUTER));
		g.drawRect(x - 4, y - 2, w + 7, h + 4);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_SELECT_BOX_INNER));
		g.drawRect(x - 3, y - 1, w + 5, h + 2);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_SELECT_BOX_OUTER));
		g.drawRect(x - 2, y, w + 3, h);
		g.drawImage(GameManager.getInstance().img_select, x, y + (h >> 1), Tools.RIGHT_VCENTER);
		Tools.drawRegion(g, GameManager.getInstance().img_select, x + w, y + (h >> 1), Tools.TRANS_H, Tools.LEFT_VCENTER);
		g.setClip(cx, cy, cw, ch);
		g.setColor(color);
	}
	
	/**
	 * 绘制一个按钮
	 * 
	 * @param g
	 * @param img
	 * @param text
	 * @param x
	 * @param y
	 */
	public static final void drawButton(Graphics g, Image img, String text, int x, int y) {
		g.drawImage(img, x, y, Tools.LEFT_TOP);
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		g.drawString(text, x + (img.getWidth() >> 1), y + ((H_BUTTON - AbstractGameScreen.FONT_H) >> 1), Tools.HCENTER_TOP);
	}

	/**
	 * 绘制单个列表标题
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param name
	 */
	public static void drawListTitleItem(Graphics g, int x, int y, int w, int h, String name) {
		g.setClip(x, y, w, h);
		int initX = x;
		int initY = y;
		int initW = w - 1;
		int initH = h - 1;
		int unitY = y + (Math.abs(h - AbstractGameScreen.s_font.getHeight()) >> 1);// 赵铮
																					// 字Y居中
		int[] colors = UIManager.getColorsSubcoatBorder();
		drawRect(g, initX, initY, initW, initH, colors[0], 0);
		drawRect(g, initX, initY, initW, initH, colors[1], 1);
		drawRect(g, initX, initY, initW, initH, colors[2], 2);
		fillRect(g, initX, initY, initW, initH, 0x395a5c, 2);
		drawColorString(g, name, initX + (w >> 1), unitY, 0xffffff, Graphics.TOP | Graphics.HCENTER);
	}

	/**
	 * xjp 绘制2层列表框
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	public static void drawListFrame(Graphics g, int x, int y, int w, int h) {
		g.setClip(x, y, w, h);
		int initX = x;
		int initY = y;
		int initW = w - 1;
		int initH = h - 1;
		int[] colors = UIManager.getColorsSubcoatBorder();
		drawRect(g, initX, initY, initW, initH, colors[0], 0);
		drawRect(g, initX, initY, initW, initH, colors[1], 1);
	}

	/**
	 * 绘制单个列表框里的边框
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color
	 * @param interval
	 */
	public static void drawRect(Graphics g, int x, int y, int w, int h, int color, int interval) {
		g.setColor(color);
		g.drawRect(x + interval, y + interval, w - (interval << 1), h - (interval << 1));
	}

	/**
	 * 绘制单个列表框里的填充
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param color
	 * @param interval
	 */
	public static void fillRect(Graphics g, int x, int y, int w, int h, int color, int interval) {
		g.setColor(color);
		g.fillRect(x + interval, y + interval, w - (interval << 1) + 1, h - (interval << 1) + 1);
	}

	/**
	 * 绘制内层窗体框
	 * */
	public static void drawInBound(Graphics g, int x, int y, int w, int h) {
		for (int i = 0; i < UIManager.getColorsSubcoatBorder().length; i++) {
			g.setColor(UIManager.getColorsSubcoatBorder()[i]);
			// 左
			g.drawLine(x + i * 1, y + i * 1, x + i * 1, y + h - i * 1);
			// 上
			g.drawLine(x + i * 1, y + i * 1, x + w - i * 1, y + i * 1);
			// 右
			g.drawLine(x + w - i * 1, y + i * 1, x + w - i * 1, y + h - i * 1);
			// 下
			g.drawLine(x + i * 1, y + h - i * 1, x + w - i * 1, y + h - i * 1);
		}
	}

}
